improve support for trial a bit more: don't run trial's empty TestCase.runTest() method
This commit is contained in:
parent
aa79c0a4b9
commit
2637326782
|
@ -10,6 +10,9 @@ Changes between 2.3.1 and 2.3.2.dev
|
||||||
- fix unittest behaviour: TestCase.runtest only called if there are
|
- fix unittest behaviour: TestCase.runtest only called if there are
|
||||||
test methods defined
|
test methods defined
|
||||||
|
|
||||||
|
- improve trial support: don't collect its empty
|
||||||
|
unittest.TestCase.runTest() method
|
||||||
|
|
||||||
- "python setup.py test" now works with pytest itself
|
- "python setup.py test" now works with pytest itself
|
||||||
|
|
||||||
- fix/improve internal/packaging related bits:
|
- fix/improve internal/packaging related bits:
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
#
|
#
|
||||||
__version__ = '2.3.2.dev8'
|
__version__ = '2.3.2.dev9'
|
||||||
|
|
|
@ -39,7 +39,10 @@ class UnitTestCase(pytest.Class):
|
||||||
foundsomething = True
|
foundsomething = True
|
||||||
|
|
||||||
if not foundsomething:
|
if not foundsomething:
|
||||||
if getattr(self.obj, 'runTest', None) is not None:
|
runtest = getattr(self.obj, 'runTest', None)
|
||||||
|
if runtest is not None:
|
||||||
|
ut = sys.modules.get("twisted.trial.unittest", None)
|
||||||
|
if ut is None or runtest != ut.TestCase.runTest:
|
||||||
yield TestCaseFunction('runTest', parent=self)
|
yield TestCaseFunction('runTest', parent=self)
|
||||||
|
|
||||||
def setup(self):
|
def setup(self):
|
||||||
|
|
|
@ -25,10 +25,13 @@ how does py.test relate to twisted's trial?
|
||||||
|
|
||||||
Since some time py.test has builtin support for supporting tests
|
Since some time py.test has builtin support for supporting tests
|
||||||
written using trial. It does not itself start a reactor, however,
|
written using trial. It does not itself start a reactor, however,
|
||||||
and does not handle Deferreds returned from a test. Someone using
|
and does not handle Deferreds returned from a test in pytest style.
|
||||||
these features might eventually write a dedicated ``pytest-twisted``
|
If you are using trial's unittest.TestCase chances are that you can
|
||||||
plugin which will surely see strong support from the pytest development
|
just run your tests even if you return Deferreds. In addition,
|
||||||
team.
|
there also is a dedicated `pytest-twisted
|
||||||
|
<http://pypi.python.org/pypi/pytest-twisted`` plugin which allows to
|
||||||
|
return deferreds from pytest-style tests, allowing to use
|
||||||
|
:ref:`fixtures` and other features.
|
||||||
|
|
||||||
how does py.test work with Django?
|
how does py.test work with Django?
|
||||||
++++++++++++++++++++++++++++++++++++++++++++++
|
++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
2
setup.py
2
setup.py
|
@ -24,7 +24,7 @@ def main():
|
||||||
name='pytest',
|
name='pytest',
|
||||||
description='py.test: simple powerful testing with Python',
|
description='py.test: simple powerful testing with Python',
|
||||||
long_description = long_description,
|
long_description = long_description,
|
||||||
version='2.3.2.dev8',
|
version='2.3.2.dev9',
|
||||||
url='http://pytest.org',
|
url='http://pytest.org',
|
||||||
license='MIT license',
|
license='MIT license',
|
||||||
platforms=['unix', 'linux', 'osx', 'cygwin', 'win32'],
|
platforms=['unix', 'linux', 'osx', 'cygwin', 'win32'],
|
||||||
|
|
|
@ -277,7 +277,27 @@ def test_testfunction_skip_property(testdir):
|
||||||
|
|
||||||
class TestTrialUnittest:
|
class TestTrialUnittest:
|
||||||
def setup_class(cls):
|
def setup_class(cls):
|
||||||
pytest.importorskip("twisted.trial.unittest")
|
cls.ut = pytest.importorskip("twisted.trial.unittest")
|
||||||
|
|
||||||
|
def test_trial_testcase_runtest_not_collected(self, testdir):
|
||||||
|
testdir.makepyfile("""
|
||||||
|
from twisted.trial.unittest import TestCase
|
||||||
|
|
||||||
|
class TC(TestCase):
|
||||||
|
def test_hello(self):
|
||||||
|
pass
|
||||||
|
""")
|
||||||
|
reprec = testdir.inline_run()
|
||||||
|
reprec.assertoutcome(passed=1)
|
||||||
|
testdir.makepyfile("""
|
||||||
|
from twisted.trial.unittest import TestCase
|
||||||
|
|
||||||
|
class TC(TestCase):
|
||||||
|
def runTest(self):
|
||||||
|
pass
|
||||||
|
""")
|
||||||
|
reprec = testdir.inline_run()
|
||||||
|
reprec.assertoutcome(passed=1)
|
||||||
|
|
||||||
def test_trial_exceptions_with_skips(self, testdir):
|
def test_trial_exceptions_with_skips(self, testdir):
|
||||||
testdir.makepyfile("""
|
testdir.makepyfile("""
|
||||||
|
@ -322,7 +342,7 @@ class TestTrialUnittest:
|
||||||
"*i2wanto*",
|
"*i2wanto*",
|
||||||
"*sys.version_info*",
|
"*sys.version_info*",
|
||||||
"*skip_in_method*",
|
"*skip_in_method*",
|
||||||
"*5 skipped*3 xfail*1 xpass*",
|
"*4 skipped*3 xfail*1 xpass*",
|
||||||
])
|
])
|
||||||
|
|
||||||
def test_trial_error(self, testdir):
|
def test_trial_error(self, testdir):
|
||||||
|
|
Loading…
Reference in New Issue