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 <>
1. NO SKIP 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"
    self.assertEqual(0, 1)


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

<unittest.result.TestResult run=1 errors=0 failures=1>
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 


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):
... why

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

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
Traceback (most recent call last):
.. 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.
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: <>
2019-04-30 04:15:51terry.reedylinkissue36674 messages
2019-04-30 04:15:50terry.reedycreate