-
-
Notifications
You must be signed in to change notification settings - Fork 35k
bpo-36674: Stops skipped tests from running in debug mode. #13180
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1777,6 +1777,31 @@ def test_something(self): | |
| self.assertEqual(len(result.skipped), 1) | ||
| self.assertEqual(result.testsRun, 1) | ||
|
|
||
| def testSkippingDebugMode(self): | ||
| def _skip(self=None): | ||
| raise unittest.SkipTest('some reason') | ||
| def nothing(self): | ||
| pass | ||
|
|
||
| class Test1(unittest.TestCase): | ||
| test_something = _skip | ||
|
|
||
| class Test2(unittest.TestCase): | ||
| setUp = _skip | ||
| test_something = nothing | ||
|
|
||
| class Test3(unittest.TestCase): | ||
| test_something = nothing | ||
| tearDown = _skip | ||
|
|
||
| class Test4(unittest.TestCase): | ||
| def test_something(self): | ||
| self.addCleanup(_skip) | ||
|
|
||
| for klass in (Test1, Test2, Test3, Test4): | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What did you mean with "klass"?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a common variable name used throughout this file (see line 1774 for example), it's a variable representing a class. |
||
| with self.assertRaises(unittest.SkipTest): | ||
| klass('test_something').debug() | ||
|
|
||
| def testSystemExit(self): | ||
| def _raise(self=None): | ||
| raise SystemExit | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| Stops skipped tests from running with TestCase.debug(), following the | ||
| functionality of TestCase.run(). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's not necessary use the round brackets for the condition.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean the parens around the if statement? It is not necessary, but encouraged by the style guide to wrap multi-line if statements in parens: https://www.python.org/dev/peps/pep-0008/#multiline-if-statements
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it's out of the scope of this PR, but I'd like to suggest a small refactoring to make this condition a little bit clearer.
_is_skipped(self, testMethod)method:not self._is_skipped(testMethod)and the existing condition around line 665 toself._is_skipped(testMethod)If it doesn't make sense to include this small update in this PR, but you think it makes sense in general, I'd be happy to work on it.