integrating review commets of @nicoddemus
plus small scale refactoring
This commit is contained in:
parent
be08223d5a
commit
696a9112be
|
@ -18,9 +18,10 @@
|
||||||
if a test suite uses ``pytest_plugins`` to load internal plugins (`#1888`_).
|
if a test suite uses ``pytest_plugins`` to load internal plugins (`#1888`_).
|
||||||
Thanks `@jaraco`_ for the report and `@nicoddemus`_ for the PR (`#1891`_).
|
Thanks `@jaraco`_ for the report and `@nicoddemus`_ for the PR (`#1891`_).
|
||||||
|
|
||||||
* Do not call tearDown (and cleanups) when running unittest with ``--pdb``
|
* Do not call tearDown and cleanups when running tests from
|
||||||
|
``unittest.TestCase`` subclasses with ``--pdb``
|
||||||
enabled. This allows proper post mortem debugging for all applications
|
enabled. This allows proper post mortem debugging for all applications
|
||||||
which have significant logic in their tearDown method (`#1890`_). Thanks
|
which have significant logic in their tearDown machinery (`#1890`_). Thanks
|
||||||
`@mbyt`_ for the PR.
|
`@mbyt`_ for the PR.
|
||||||
|
|
||||||
*
|
*
|
||||||
|
|
|
@ -153,7 +153,7 @@ class TestCaseFunction(pytest.Function):
|
||||||
if self.config.pluginmanager.get_plugin("pdbinvoke") is None:
|
if self.config.pluginmanager.get_plugin("pdbinvoke") is None:
|
||||||
self._testcase(result=self)
|
self._testcase(result=self)
|
||||||
else:
|
else:
|
||||||
# disables tearDown and cleanups for post mortem debugging
|
# disables tearDown and cleanups for post mortem debugging (see #1890)
|
||||||
self._testcase.debug()
|
self._testcase.debug()
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -33,6 +33,13 @@ distributing tests to multiple CPUs via the ``-nNUM`` option if you
|
||||||
installed the ``pytest-xdist`` plugin. Please refer to
|
installed the ``pytest-xdist`` plugin. Please refer to
|
||||||
the general ``pytest`` documentation for many more examples.
|
the general ``pytest`` documentation for many more examples.
|
||||||
|
|
||||||
|
.. note::
|
||||||
|
|
||||||
|
Running tests from ``unittest.TestCase`` subclasses with ``--pdb`` will
|
||||||
|
disable tearDown and cleanup methods for the case that an Exception is
|
||||||
|
occurs. This allows proper post mortem debugging for all applications
|
||||||
|
which have significant logic in their tearDown machinery.
|
||||||
|
|
||||||
Mixing pytest fixtures into unittest.TestCase style tests
|
Mixing pytest fixtures into unittest.TestCase style tests
|
||||||
-----------------------------------------------------------
|
-----------------------------------------------------------
|
||||||
|
|
||||||
|
|
|
@ -86,7 +86,7 @@ class TestPDB:
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
self.filename = None
|
self.filename = None
|
||||||
def test_false(self):
|
def test_false(self):
|
||||||
self.filename = 'bla' + '.txt'
|
self.filename = 'debug' + '.me'
|
||||||
assert 0
|
assert 0
|
||||||
""")
|
""")
|
||||||
child = testdir.spawn_pytest("--pdb %s" % p1)
|
child = testdir.spawn_pytest("--pdb %s" % p1)
|
||||||
|
@ -94,7 +94,7 @@ class TestPDB:
|
||||||
child.sendline('p self.filename')
|
child.sendline('p self.filename')
|
||||||
child.sendeof()
|
child.sendeof()
|
||||||
rest = child.read().decode("utf8")
|
rest = child.read().decode("utf8")
|
||||||
assert 'bla.txt' in rest
|
assert 'debug.me' in rest
|
||||||
if child.isalive():
|
if child.isalive():
|
||||||
child.wait()
|
child.wait()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue