This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author terry.reedy
Recipients dmaurer, ezio.melotti, lisroach, michael.foord, rbcollins, terry.reedy
Date 2019-04-30.04:15:50
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1556597751.23.0.205397717401.issue36674@roundup.psfhosted.org>
In-reply-to
Content
1. NO SKIP utest.py with debug prints added and @skipIf initially commented out.
---
from unittest import TestCase, skipIf

#@skipIf(True, "Skip Testing")
class Tests(TestCase):
  def test_skip(self):
    "this test will fail - if not skipped"
    print('asserting')
    self.assertEqual(0, 1)

print(Tests("test_skip").run())
print(Tests("test_skip").debug())
---

test_skip is run twice, with the output difference being as documented.

asserting
<unittest.result.TestResult run=1 errors=0 failures=1>
asserting
Traceback (most recent call last):
...
AssertionError: 0 != 1


2. SKIPTEST Adding "self.skipTest('why')" either in a new setUp() or at the top of skip_test() and adding another print 

print(Tests("test_skip").run().skipped)

results in the output I expect from the doc.

<unittest.result.TestResult run=1 errors=0 failures=0>
[(<__main__.Tests testMethod=test_skip>, 'why')]
Traceback (most recent call last):
...
unittest.case.SkipTest: why


3. SKIPIF CLASS Uncommenting @skipIf (the OP's case) instead results in

None
asserting
Traceback ...
AssertionError: 0 != 1

Since .run does not run the test, I agree that debug() running the test and raising AssertionError is a bug.  The test should not be run.  In my original comments, I expected SkipTest, as in cases 2 above and 4 below.  I have not yet checked the current tests.


4. SKIPIF FUNC Moving the skipIf decorator to test_skip results in
None
Traceback (most recent call last):
..
unittest.case.SkipTest: Skip Testing

I don't know why run() returns None for skipIf cases instead of returning a TestResult with non-empty skipped, as it does for skipTest, or if the None is a separate bug.
History
Date User Action Args
2019-04-30 04:15:51terry.reedysetrecipients: + terry.reedy, dmaurer, rbcollins, ezio.melotti, michael.foord, lisroach
2019-04-30 04:15:51terry.reedysetmessageid: <1556597751.23.0.205397717401.issue36674@roundup.psfhosted.org>
2019-04-30 04:15:51terry.reedylinkissue36674 messages
2019-04-30 04:15:50terry.reedycreate