[New-bugs-announce] [issue41046] unittest: make skipTest a classmethod

James Corbett report at bugs.python.org
Fri Jun 19 20:36:33 EDT 2020

New submission from James Corbett <james.h.corbett at gmail.com>:

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

    def ready_for_tests(cls):

    def setUpClass(cls):
        if not cls.ready_for_tests():

components: Library (Lib)
messages: 371914
nosy: jameshcorbett
priority: normal
severity: normal
status: open
title: unittest: make skipTest a classmethod
type: enhancement
versions: Python 3.9

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list