[Tests] Changes to tests and test configs of Travis/tox

* Added pip chaching
* Added disable_new_release_check to tracker icons tests
* Fixed test_torrentview
* Require minimum tox version 1.8
* Fixed GTKUI tests and testcoverage by using xvfb on travis
* Separated the apt dependencies for commands requiering GTKUI deps
This commit is contained in:
bendikro 2014-10-13 16:57:46 +02:00 committed by Calum Lind
commit 448261394f
6 changed files with 73 additions and 34 deletions

View file

@ -1,37 +1,50 @@
language: python language: python
python: python:
# - "2.6"
- "2.7" - "2.7"
# command to install dependencies # Cache packages download with apt
install: cache:
- pip install tox directories:
- $HOME/.pip-cache/
before_install:
- lsb_release -a - lsb_release -a
- sudo add-apt-repository ppa:deluge-team/ppa -y - sudo add-apt-repository ppa:deluge-team/ppa -y
- sudo apt-get update - sudo apt-get update
- sudo apt-get install python-libtorrent
script: # command to install dependencies
- tox install:
- bash -c "echo $APTPACKAGES"
- sudo apt-get install $APTPACKAGES
- pip install "tox>=1.8" --download-cache $HOME/.pip-cache
env: env:
- TOX_ENV=pydef global:
- TOX_ENV=trial - PIP_DOWNLOAD_CACHE=$HOME/.pip-cache/
- TOX_ENV=todo - APTPACKAGES="python-libtorrent"
# - TOX_ENV=plugins - APTPACKAGES_GTKUI="python-gobject python-glade2"
- TOX_ENV=flake8 matrix:
- TOX_ENV=flake8-complexity - TOX_ENV=pydef
- TOX_ENV=isort - TOX_ENV=flake8
- TOX_ENV=docs - TOX_ENV=flake8-complexity
- TOX_ENV=testcoverage - TOX_ENV=isort
- TOX_ENV=docs
- TOX_ENV=todo
- TOX_ENV=trial APTPACKAGES="$APTPACKAGES $APTPACKAGES_GTKUI"
- TOX_ENV=pygtkui APTPACKAGES="$APTPACKAGES $APTPACKAGES_GTKUI"
- TOX_ENV=testcoverage APTPACKAGES="$APTPACKAGES $APTPACKAGES_GTKUI"
# - TOX_ENV=plugins
virtualenv: virtualenv:
system_site_packages: true system_site_packages: true
# We use xvfb for the GTKUI tests
before_script: before_script:
- export PYTHONPATH=$PYTHONPATH:$PWD - export PYTHONPATH=$PYTHONPATH:$PWD
- python -c "import libtorrent as lt; print lt.version" - python -c "import libtorrent as lt; print lt.version"
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
script: script:
- tox -e $TOX_ENV - tox -e $TOX_ENV

View file

@ -1,13 +1,18 @@
from twisted.trial import unittest import deluge.component as component
from deluge.core.authmanager import AUTH_LEVEL_ADMIN, AuthManager from deluge.core.authmanager import AUTH_LEVEL_ADMIN, AuthManager
from .basetest import BaseTestCase
class AuthManagerTestCase(unittest.TestCase):
def setUp(self): # NOQA class AuthManagerTestCase(BaseTestCase):
def set_up(self):
self.auth = AuthManager() self.auth = AuthManager()
self.auth.start() self.auth.start()
def tear_down(self):
# We must ensure that the components in component registry are removed
return component.shutdown()
def test_authorize(self): def test_authorize(self):
from deluge.ui import common from deluge.ui import common
self.assertEquals( self.assertEquals(

View file

@ -1,12 +1,13 @@
from twisted.internet import defer from twisted.internet import defer
from twisted.internet.error import CannotListenError from twisted.internet.error import CannotListenError
from twisted.trial import unittest
import deluge.component as component
from deluge import error from deluge import error
from deluge.core.authmanager import AUTH_LEVEL_ADMIN from deluge.core.authmanager import AUTH_LEVEL_ADMIN
from deluge.ui.client import Client, DaemonSSLProxy, client from deluge.ui.client import Client, DaemonSSLProxy, client
from . import common from . import common
from .basetest import BaseTestCase
class NoVersionSendingDaemonSSLProxy(DaemonSSLProxy): class NoVersionSendingDaemonSSLProxy(DaemonSSLProxy):
@ -63,9 +64,9 @@ class NoVersionSendingClient(Client):
self.disconnect_callback() self.disconnect_callback()
class ClientTestCase(unittest.TestCase): class ClientTestCase(BaseTestCase):
def setUp(self): # NOQA def set_up(self):
self.listen_port = 58846 self.listen_port = 58846
tries = 10 tries = 10
error = None error = None
@ -82,8 +83,9 @@ class ClientTestCase(unittest.TestCase):
if error: if error:
raise error raise error
def tearDown(self): # NOQA def tear_down(self):
self.core.terminate() self.core.terminate()
return component.shutdown()
def test_connect_no_credentials(self): def test_connect_no_credentials(self):
d = client.connect( d = client.connect(

View file

@ -1,16 +1,28 @@
import pytest import pytest
import gobject
from twisted.trial import unittest from twisted.trial import unittest
import deluge.common import deluge.common
import deluge.component as component import deluge.component as component
from deluge.ui.gtkui.mainwindow import MainWindow from deluge.configmanager import ConfigManager
from deluge.ui.gtkui.menubar import MenuBar
from deluge.ui.gtkui.torrentdetails import TorrentDetails
from deluge.ui.gtkui.torrentview import TorrentView
from . import common
from .basetest import BaseTestCase from .basetest import BaseTestCase
libs_available = True
# Allow running other tests without GTKUI dependencies available
try:
from gobject import TYPE_UINT64
from deluge.ui.gtkui.mainwindow import MainWindow
from deluge.ui.gtkui.menubar import MenuBar
from deluge.ui.gtkui.torrentdetails import TorrentDetails
from deluge.ui.gtkui.torrentview import TorrentView
from deluge.ui.gtkui.gtkui import DEFAULT_PREFS
except ImportError as err:
libs_available = False
TYPE_UINT64 = "Whatever"
import traceback
traceback.print_exc()
deluge.common.setup_translations() deluge.common.setup_translations()
@ -23,13 +35,19 @@ class TorrentviewTestCase(BaseTestCase):
u'Up Speed', u'Down Limit', u'Up Limit', u'ETA', u'Ratio', u'Up Speed', u'Down Limit', u'Up Limit', u'ETA', u'Ratio',
u'Avail', u'Added', u'Completed', u'Complete Seen', u'Avail', u'Added', u'Completed', u'Complete Seen',
u'Tracker', u'Download Folder', u'Owner', u'Shared'] u'Tracker', u'Download Folder', u'Owner', u'Shared']
default_liststore_columns = [bool, str, bool, int, str, str, gobject.TYPE_UINT64, default_liststore_columns = [bool, str, bool, int, str, str, TYPE_UINT64,
gobject.TYPE_UINT64, gobject.TYPE_UINT64, gobject.TYPE_UINT64, TYPE_UINT64, TYPE_UINT64, TYPE_UINT64,
float, str, int, int, int, int, float, float, float, float, str, int, int, int, int, float, float, float,
float, float, int, float, float, float, float, float, float, int, float, float, float, float,
float, str, str, str, str, bool] float, str, str, str, str, bool]
def set_up(self): def set_up(self):
if libs_available is False:
raise unittest.SkipTest("GTKUI dependencies not available")
common.set_tmp_config_dir()
# MainWindow loads this config file, so lets make sure it contains the defaults
ConfigManager("gtkui.conf", defaults=DEFAULT_PREFS)
self.mainwindow = MainWindow() self.mainwindow = MainWindow()
self.torrentview = TorrentView() self.torrentview = TorrentView()
self.torrentdetails = TorrentDetails() self.torrentdetails = TorrentDetails()

View file

@ -4,12 +4,13 @@ import deluge.component as component
import deluge.ui.tracker_icons import deluge.ui.tracker_icons
from deluge.ui.tracker_icons import TrackerIcon, TrackerIcons from deluge.ui.tracker_icons import TrackerIcon, TrackerIcons
from . import common
from .basetest import BaseTestCase from .basetest import BaseTestCase
from .common import set_tmp_config_dir
set_tmp_config_dir() common.set_tmp_config_dir()
dirname = os.path.dirname(__file__) dirname = os.path.dirname(__file__)
deluge.ui.tracker_icons.PIL_INSTALLED = False deluge.ui.tracker_icons.PIL_INSTALLED = False
common.disable_new_release_check()
class TrackerIconsTestCase(BaseTestCase): class TrackerIconsTestCase(BaseTestCase):

View file

@ -120,7 +120,7 @@ whitelist_externals =
{[testenv]whitelist_externals} {[testenv]whitelist_externals}
coverage coverage
commands = commands =
coverage run --branch --source=deluge -m py.test "not (todo or gtkui)" deluge/tests/ coverage run --branch --source=deluge -m py.test -m "not todo" deluge/tests/
[testenv:testcoverage] [testenv:testcoverage]
deps = {[testcoveragebase]deps} deps = {[testcoveragebase]deps}