Skip to content

Commit

Permalink
avoid tearDown and cleanup for unittest debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
mbyt committed Aug 30, 2016
1 parent 8593bb1 commit 4eeb475
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion _pytest/unittest.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,12 @@ def stopTest(self, testcase):
pass

def runtest(self):
self._testcase(result=self)
if self.config.pluginmanager.get_plugin("pdbinvoke") is None:
self._testcase(result=self)
else:
# disables tearDown and cleanups for post mortem debugging
self._testcase.debug()


def _prunetraceback(self, excinfo):
pytest.Function._prunetraceback(self, excinfo)
Expand Down

4 comments on commit 4eeb475

@tricosmo
Copy link

@tricosmo tricosmo commented on 4eeb475 Sep 14, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi mbyt

Recently we have problem to run "pytest --pdb" with our flask testcases. The testcases were fine until this change. The case is when we add --pdb option all the case failed with the same reason. "self.app is None", but if no "--pdb" then all tests pass.

By debugging, we found that this _pre_setup function
https://github.com/jarus/flask-testing/blob/master/flask_testing/utils.py#L102 is called to setup self.app.
But since the change, it calls the debug function instead of the Testcase which will skip the whole pre_setup function.

I tried to customise our own debug function to call pre_setup, but failed with further issues(request mocker). So I am wondering if I am doing right, or this is an issue I can address with flask_testing.

For now we just use previous version of pytest, but we like to be as close as possible to the latest. Any advise will be appreciated. Thanks

Niansheng

@RonnyPfannschmidt
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@niansheng please report a regular issue, we will then decide if we can figure a fix quickly or if we need to undo this until it is correctly working

@tricosmo
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will do thanks Ronny

@RonnyPfannschmidt
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just adding the backreference - #1932

Please sign in to comment.