Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
unittest: handle outcomes.Exit #5634
Initial test, but testing for outcomes.Exit is faster / more concise:
diff --git i/testing/test_pdb.py w/testing/test_pdb.py index 8d327cbb3..602db0aa7 100644 --- i/testing/test_pdb.py +++ w/testing/test_pdb.py @@ -189,6 +189,30 @@ def test_one(self): child.sendeof() self.flush(child) + def test_pdb_unittest_quit(self, testdir): + p1 = testdir.makepyfile( + """ + import unittest + + class MyTestCase(unittest.TestCase): + # class TestClass: + def test_one(self): + __import__('pdb').set_trace() + + def test_two(self): + pass + """ + ) + child = testdir.spawn_pytest("%s" % p1) + child.expect("Pdb") + child.sendline("q") + child.expect_exact("Exit: Quitting debugger") + rest = child.read().decode("utf8") + assert "no tests ran in" in rest + assert "reading from stdin while output" not in rest + # Only printed once - not on stderr. + assert "Exit: Quitting debugger" not in child.before.decode("utf8") + def test_pdb_print_captured_stdout_and_stderr(self, testdir): p1 = testdir.makepyfile( """
@@ Coverage Diff @@ ## master #5634 +/- ## ========================================== + Coverage 96.11% 96.12% +0.01% ========================================== Files 117 117 Lines 25770 25787 +17 Branches 2495 2494 -1 ========================================== + Hits 24769 24788 +19 + Misses 696 695 -1 + Partials 305 304 -1
Jul 23, 2019
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews.