Author zach.ware
Recipients Naitree Zhu, steven.daprano, zach.ware
Date 2018-09-06.14:25:26
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1536243926.6.0.56676864532.issue34596@psf.upfronthosting.co.za>
In-reply-to
Content
It could be interesting to enable uncalled `skip` by setting a default reason of "Unconditional skip" when the argument is a function.

Do note that decorating with an uncalled `skip` does actually work to skip the test currently, but the test is marked as success rather than skipped (see example pasted below).  For this reason, I don't think we should turn it into an error in maintenance releases, as anyone using this accidentally will suddenly have many failing tests.

$ cat test.py
from unittest import TestCase, skip


class Test(TestCase):

    def test_good(self):
        self.assertTrue(1.0)

    def test_bad(self):
        self.assertFalse(1.0)

    @skip
    def test_bad_skip(self):
        self.assertFalse(1.0)

    @skip('always skipped')
    def test_good_skip(self):
        self.assertFalse(1.0)

$ ./python.exe -m unittest test.py -v
test_bad (test.Test) ... FAIL
test_bad_skip (test.Test) ... ok
test_good (test.Test) ... ok
test_good_skip (test.Test) ... skipped 'always skipped'

======================================================================
FAIL: test_bad (test.Test)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/.../test.py", line 10, in test_bad
    self.assertFalse(1.0)
AssertionError: 1.0 is not false

----------------------------------------------------------------------
Ran 4 tests in 0.002s

FAILED (failures=1, skipped=1)
History
Date User Action Args
2018-09-06 14:25:26zach.waresetrecipients: + zach.ware, steven.daprano, Naitree Zhu
2018-09-06 14:25:26zach.waresetmessageid: <1536243926.6.0.56676864532.issue34596@psf.upfronthosting.co.za>
2018-09-06 14:25:26zach.warelinkissue34596 messages
2018-09-06 14:25:26zach.warecreate