Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
unittest runner: avoid tearDown and cleanup to ease post mortem debugging #1890
Assuming pytest is used to run a GUI test unittest suite. Typically GUI tests close the GUI in the unittest tearDowns or cleanup methods.
These tests cannot be easily post mortem debugged (
A work around when running the unittest via the unittest runner is to add the following line to ~/.pdbrc:
This pull request accomplishes the same within the pytest unittest compatibility layer. It is solely activated if pytest ist called with --pdb.
An example program which shows the problem would be the following (run with and without this change):
Hey @mbyt, thanks for the PR.
TBH I'm reluctant of adding such an esoteric use-case to pytest core, specially on the
You can accomplish something similar by adding this to your
def pytest_configure(config): if config.getvalue("usepdb"): import _pytest.unittest _pytest.unittest.TestCaseFunction.runtest = lambda self,*args,**kw: self._testcase.debug()
Hmm now that I thought a little more and played around a bit, I think actually we somehow should make it possible to use
import unittest class Test(unittest.TestCase): def tearDown(self): self.filename = None def test_1(self): assert 1 def test_2(self): self.filename = 'debug me' assert 0
One might even argue that
What do others think?
Other than my comments above, would you mind adding a small blurb to the docs mentioning this change? I think adding a