Author jameshcorbett
Recipients jameshcorbett
Date 2020-06-20.00:36:33
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1592613393.95.0.180040510992.issue41046@roundup.psfhosted.org>
In-reply-to
Content
The `unittest.TestCase.skipTest` method, used to skip the current test, is currently an instance method. There's nothing to stop it from being a `classmethod` or a `staticmethod` though---it doesn't use its reference to `self` since it's just a wrapper around the `SkipTest` exception. Making it a `classmethod` or `staticmethod` would allow calling the method from `setUpClass`. Here's an example:

```
import unittest

class MyTestCase(unittest.TestCase):

    @classmethod
    def ready_for_tests(cls):
        pass

    @classmethod
    def setUpClass(cls):
        if not cls.ready_for_tests():
            cls.skipTest()
```
History
Date User Action Args
2020-06-20 00:36:33jameshcorbettsetrecipients: + jameshcorbett
2020-06-20 00:36:33jameshcorbettsetmessageid: <1592613393.95.0.180040510992.issue41046@roundup.psfhosted.org>
2020-06-20 00:36:33jameshcorbettlinkissue41046 messages
2020-06-20 00:36:33jameshcorbettcreate