From f1bdb959342772937b2d4de139b929bb0f5855a0 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Tue, 1 Nov 2016 10:16:39 -0400 Subject: Optionally use pytest as the test runner --- .hgignore | 1 + igor.py | 9 +++++++-- tests/test_oddball.py | 3 ++- tox.ini | 1 + 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/.hgignore b/.hgignore index ec63472d..700b12fe 100644 --- a/.hgignore +++ b/.hgignore @@ -27,6 +27,7 @@ MANIFEST setuptools-*.egg .tox* .noseids +.cache # Stuff in the test directory. zipmods.zip diff --git a/igor.py b/igor.py index 54b8da16..77c97d3c 100644 --- a/igor.py +++ b/igor.py @@ -102,8 +102,13 @@ def run_tests(tracer, *nose_args): if 'COVERAGE_TESTING' not in os.environ: os.environ['COVERAGE_TESTING'] = "True" print_banner(label_for_tracer(tracer)) - nose_args = ["nosetests"] + list(nose_args) - nose.core.main(argv=nose_args) + if 'COVERAGE_PYTEST' in os.environ: + import pytest + runner_args = list(nose_args) + pytest.main(runner_args) + else: + nose_args = ["nosetests"] + list(nose_args) + nose.core.main(argv=nose_args) def run_tests_with_coverage(tracer, *nose_args): diff --git a/tests/test_oddball.py b/tests/test_oddball.py index 87c65b0e..7fc122af 100644 --- a/tests/test_oddball.py +++ b/tests/test_oddball.py @@ -353,7 +353,8 @@ class DoctestTest(CoverageTest): # of coverage will get. Deleting the imported module here is # enough: when the test imports doctest again, it will get a fresh # copy without the monkeypatch. - del sys.modules['doctest'] + if 'doctest' in sys.modules: + del sys.modules['doctest'] def test_doctest(self): self.check_coverage('''\ diff --git a/tox.ini b/tox.ini index a8c48271..669f6b32 100644 --- a/tox.ini +++ b/tox.ini @@ -10,6 +10,7 @@ usedevelop = True deps = # https://requires.io/github/nedbat/coveragepy/requirements/ + pytest pip==8.1.2 nose==1.3.7 mock==2.0.0 -- cgit v1.2.1