From 2280a533c05034791005f7d2de7f7e5bcedab034 Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Thu, 5 Mar 2015 00:35:20 +0100 Subject: [PATCH 1/5] Use py.test as test runner --- dev-requirements.txt | 7 +++---- docs/contributing.rst | 4 ++-- docs/extensiondev.rst | 5 ----- setup.py | 5 ----- tasks.py | 6 ++---- tests/__main__.py | 5 ----- tox.ini | 10 +++++----- 7 files changed, 12 insertions(+), 30 deletions(-) delete mode 100644 tests/__main__.py diff --git a/dev-requirements.txt b/dev-requirements.txt index 7b0e96c8..eba66348 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -12,12 +12,11 @@ flake8-import-order mock # Test runners -nose +pytest +pytest-cov +pytest-xdist tox -# Measure test's code coverage -coverage - # Check that MANIFEST.in matches Git repo contents before making a release check-manifest diff --git a/docs/contributing.rst b/docs/contributing.rst index 165fee49..f30e16bd 100644 --- a/docs/contributing.rst +++ b/docs/contributing.rst @@ -89,11 +89,11 @@ Mopidy to come with tests. #. To run all tests, go to the project directory and run:: - nosetests + py.test To run tests with test coverage statistics:: - nosetests --with-coverage + py.test --cov=mopidy --cov-report=term-missing Test coverage statistics can also be viewed online at `coveralls.io `_. diff --git a/docs/extensiondev.rst b/docs/extensiondev.rst index c6a88619..93f627dc 100644 --- a/docs/extensiondev.rst +++ b/docs/extensiondev.rst @@ -189,11 +189,6 @@ class that will connect the rest of the dots. 'Pykka >= 1.1', 'pysoundspot', ], - test_suite='nose.collector', - tests_require=[ - 'nose', - 'mock >= 1.0', - ], entry_points={ 'mopidy.ext': [ 'soundspot = mopidy_soundspot:Extension', diff --git a/setup.py b/setup.py index 384aaec5..0d29c041 100644 --- a/setup.py +++ b/setup.py @@ -29,11 +29,6 @@ setup( 'tornado >= 2.3', ], extras_require={'http': []}, - test_suite='nose.collector', - tests_require=[ - 'nose', - 'mock >= 1.0', - ], entry_points={ 'console_scripts': [ 'mopidy = mopidy.__main__:main', diff --git a/tasks.py b/tasks.py index 7b5692e3..9353eb8a 100644 --- a/tasks.py +++ b/tasks.py @@ -15,11 +15,9 @@ def test(path=None, coverage=False, watch=False, warn=False): if watch: return watcher(test, path=path, coverage=coverage) path = path or 'tests/' - cmd = 'nosetests' + cmd = 'py.test' if coverage: - cmd += ( - ' --with-coverage --cover-package=mopidy' - ' --cover-branches --cover-html') + cmd += ' --cov=mopidy --cov-report=term-missing' cmd += ' %s' % path run(cmd, pty=True, warn=warn) diff --git a/tests/__main__.py b/tests/__main__.py deleted file mode 100644 index ae7a18e6..00000000 --- a/tests/__main__.py +++ /dev/null @@ -1,5 +0,0 @@ -from __future__ import absolute_import, unicode_literals - -import nose - -nose.main() diff --git a/tox.ini b/tox.ini index 277ae9d3..3d48e311 100644 --- a/tox.ini +++ b/tox.ini @@ -3,20 +3,20 @@ envlist = py27, py27-tornado23, py27-tornado31, docs, flake8 [testenv] sitepackages = true -commands = nosetests -v --with-xunit --xunit-file=xunit-{envname}.xml --with-coverage --cover-package=mopidy +commands = py.test --junit-xml=xunit-{envname}.xml --cov=mopidy deps = - coverage mock - nose + pytest + pytest-cov [testenv:py27-tornado23] -commands = nosetests -v tests/http +commands = py.test tests/http deps = {[testenv]deps} tornado==2.3 [testenv:py27-tornado31] -commands = nosetests -v tests/http +commands = py.test tests/http deps = {[testenv]deps} tornado==3.1.1 From c916fcb421ff07dede3efbb73528dd8673fd134d Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Thu, 5 Mar 2015 09:16:32 +0100 Subject: [PATCH 2/5] tox: Use env specific tmpdir for py.test --- tox.ini | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index 3d48e311..bffdb2df 100644 --- a/tox.ini +++ b/tox.ini @@ -3,7 +3,10 @@ envlist = py27, py27-tornado23, py27-tornado31, docs, flake8 [testenv] sitepackages = true -commands = py.test --junit-xml=xunit-{envname}.xml --cov=mopidy +commands = + py.test \ + --basetemp={envtmpdir} \ + --junit-xml=xunit-{envname}.xml --cov=mopidy deps = mock pytest From d89041e1d3c34843decf79630436483662a5e670 Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Thu, 5 Mar 2015 09:16:46 +0100 Subject: [PATCH 3/5] tox: Pass args to py.test, include pytest-xdist --- tox.ini | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index bffdb2df..ad43d9ec 100644 --- a/tox.ini +++ b/tox.ini @@ -6,11 +6,13 @@ sitepackages = true commands = py.test \ --basetemp={envtmpdir} \ - --junit-xml=xunit-{envname}.xml --cov=mopidy + --junit-xml=xunit-{envname}.xml --cov=mopidy \ + {posargs} deps = mock pytest pytest-cov + pytest-xdist [testenv:py27-tornado23] commands = py.test tests/http From 1119555809a03be7bc8029b375ae97ad5b2241fd Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Thu, 5 Mar 2015 12:27:18 +0100 Subject: [PATCH 4/5] core: Remove deprecated property warnings Their use of inspect (I think) made parallel test execution slower than serial test execution. --- mopidy/utils/deprecation.py | 35 ++++++++--------------------------- 1 file changed, 8 insertions(+), 27 deletions(-) diff --git a/mopidy/utils/deprecation.py b/mopidy/utils/deprecation.py index 1b744702..bf4756d7 100644 --- a/mopidy/utils/deprecation.py +++ b/mopidy/utils/deprecation.py @@ -1,34 +1,15 @@ from __future__ import unicode_literals -import inspect -import warnings - - -def _is_pykka_proxy_creation(): - stack = inspect.stack() - try: - calling_frame = stack[3] - except IndexError: - return False - else: - filename = calling_frame[1] - funcname = calling_frame[3] - return 'pykka' in filename and funcname == '_get_attributes' - def deprecated_property( getter=None, setter=None, message='Property is deprecated'): - def deprecated_getter(*args): - if not _is_pykka_proxy_creation(): - warnings.warn(message, DeprecationWarning, stacklevel=2) - return getter(*args) + # During development, this is a convenient place to add logging, emit + # warnings, or ``assert False`` to ensure you are not using any of the + # deprecated properties. + # + # Using inspect to find the call sites to emit proper warnings makes + # parallel execution of our test suite slower than serial execution. Thus, + # we don't want to add any extra overhead here by default. - def deprecated_setter(*args): - if not _is_pykka_proxy_creation(): - warnings.warn(message, DeprecationWarning, stacklevel=2) - return setter(*args) - - new_getter = getter and deprecated_getter - new_setter = setter and deprecated_setter - return property(new_getter, new_setter) + return property(getter, setter) From 67a41b980a7049690f9c7cc229c1c7da46d6a9e5 Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Thu, 5 Mar 2015 12:28:31 +0100 Subject: [PATCH 5/5] tox: Run tests with 4 processes in parallel --- tox.ini | 1 + 1 file changed, 1 insertion(+) diff --git a/tox.ini b/tox.ini index ad43d9ec..e6470146 100644 --- a/tox.ini +++ b/tox.ini @@ -7,6 +7,7 @@ commands = py.test \ --basetemp={envtmpdir} \ --junit-xml=xunit-{envname}.xml --cov=mopidy \ + -n 4 \ {posargs} deps = mock