Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Fix issue where using the skip* family of decorators still ran the setUp and tearDown test methods. #103
Conversation
|
Also CI failed - you'll need to fix that :) |
rbtcollins
reviewed
Sep 1, 2014
| @@ -112,6 +112,10 @@ def _run_prepared_result(self, result): | ||
| def _run_core(self): | ||
| """Run the user supplied test code.""" | ||
| + if getattr(self.case._get_test_method(), '__unittest_skip__', False): | ||
| + self.result.addSuccess(self.case, details=self.case.getDetails()) |
thomir
Sep 1, 2014
Member
I think so. As far as I can make out, this is what it was doing before, and there are explicit tests for the 2.6 and 2.7 result objects (see test_testcase.py:1303-1364).
rbtcollins
reviewed
Sep 1, 2014
| + | ||
| + def __init__(self, *args): | ||
| + super(SkippingTest, self).__init__(*args) | ||
| + self.setup_ran = False |
rbtcollins
Sep 1, 2014
Owner
btw having the default of False on the class was fine, you don't need the init - you just can't store it there per-test.
rbtcollins
reviewed
Sep 1, 2014
| + test = SkippingTest('test_skipped') | ||
| + result = test.run() | ||
| + self.assertTrue(result.wasSuccessful()) | ||
| + self.assertFalse(test.setup_ran) |
rbtcollins
reviewed
Sep 1, 2014
| + unittest.skipIf(True, "Skip this test") | ||
| + ) | ||
| + | ||
| + @skipIf(sys.version < '2.7', "no unittest.skipUnless in Py2.6") |
rbtcollins
Sep 1, 2014
Owner
You might like to factor this out into a constant
require_27 = skipIf(...)
...
@require_27
added a commit
that referenced
this pull request
Sep 1, 2014
rbtcollins
merged commit b04e714
into
testing-cabal:master
Sep 1, 2014
1 check passed
continuous-integration/travis-ci
The Travis CI build passed
Details
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thomir commentedSep 1, 2014
This closes #86.
I make the testtools skip decorator set the unittest_skip attribute on test methods, which makes them compatible with the unittest functions of the same name.
I then change RunTest._run_core to look for that attribute and not run setUp if it's present.