diff --git a/.travis.yml b/.travis.yml index 45c8a1e3..684ac64a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -30,7 +30,5 @@ before_script: flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics; fi -# command to run tests, e.g. python setup.py test - script: - tox diff --git a/TESTING.txt b/TESTING.txt index 68a1c971..1c29b6a6 100644 --- a/TESTING.txt +++ b/TESTING.txt @@ -1,9 +1,7 @@ Currently the tests are passing on OS X and Linux on Python 2.7 and 3.4. -The test suite can be run either with: +The test suite can be run with: - $ python setup.py test + $ tox -which uses the unittest module's test discovery mechanism, or with: - - $ py.test +which tests the module under a number of different python versions, where available. diff --git a/discover_tests.py b/discover_tests.py deleted file mode 100644 index 1d289418..00000000 --- a/discover_tests.py +++ /dev/null @@ -1,57 +0,0 @@ -""" -Simple auto test discovery. - -From http://stackoverflow.com/a/17004409 -""" -import os -import sys -import unittest - -if not hasattr(unittest.defaultTestLoader, 'discover'): - try: - import unittest2 as unittest - except ImportError: - raise ImportError('The unittest2 module is required to run tests on Python 2.6') - -def additional_tests(): - setup_file = sys.modules['__main__'].__file__ - setup_dir = os.path.abspath(os.path.dirname(setup_file)) - test_dir = os.path.join(setup_dir, 'tests') - test_suite = unittest.defaultTestLoader.discover(test_dir) - blacklist = [] - if '/home/travis' in __file__: - # Skip some tests that fail on travis-ci - blacklist.append('test_command') - return exclude_tests(test_suite, blacklist) - - -class SkipCase(unittest.TestCase): - def skeleton_run_test(self): - raise unittest.SkipTest("Test fails spuriously on travis-ci") - - -def exclude_tests(suite, blacklist): - """ - Example: - - blacklist = [ - 'test_some_test_that_should_be_skipped', - 'test_another_test_that_should_be_skipped' - ] - """ - new_suite = unittest.TestSuite() - - for test_group in suite._tests: - for test in test_group: - if not hasattr(test, '_tests'): - # e.g. ModuleImportFailure - new_suite.addTest(test) - continue - for subtest in test._tests: - method = subtest._testMethodName - if method in blacklist: - setattr(test, - method, - getattr(SkipCase(), 'skeleton_run_test')) - new_suite.addTest(test) - return new_suite diff --git a/setup.py b/setup.py index 62644437..05ee3243 100755 --- a/setup.py +++ b/setup.py @@ -78,7 +78,6 @@ 'LICENSE.txt', 'futurize.py', 'pasteurize.py', - 'discover_tests.py', 'check_rst.sh', 'TESTING.txt', ], @@ -177,6 +176,5 @@ include_package_data=True, python_requires=">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*", classifiers=CLASSIFIERS, - test_suite = "discover_tests", **setup_kwds ) diff --git a/tox.ini b/tox.ini index 1f0f1705..96f949a3 100644 --- a/tox.ini +++ b/tox.ini @@ -2,4 +2,5 @@ envlist = py27,py34,py35,py36,py37 [testenv] -commands = python setup.py test +deps = pytest +commands = pytest {posargs}