diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2012-04-25 12:56:46 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2012-04-25 12:56:46 (GMT) |
commit | b05ac864f048bfeb184e93be71aebd6223a76eec (patch) | |
tree | 962db75f0fc559bb47ae45601295cd18bd8f7fdf | |
parent | c2ad0aa9f1bc89e6da38f81af9ca05e921fa725c (diff) | |
download | cpython-b05ac864f048bfeb184e93be71aebd6223a76eec.zip cpython-b05ac864f048bfeb184e93be71aebd6223a76eec.tar.gz cpython-b05ac864f048bfeb184e93be71aebd6223a76eec.tar.bz2 |
Issue #14664: It is now possible to use @unittest.skip{If,Unless} on a test class that doesn't inherit from TestCase (i.e. a mixin).
-rw-r--r-- | Lib/unittest/case.py | 2 | ||||
-rw-r--r-- | Lib/unittest/test/test_skipping.py | 15 | ||||
-rw-r--r-- | Misc/NEWS | 3 |
3 files changed, 19 insertions, 1 deletions
diff --git a/Lib/unittest/case.py b/Lib/unittest/case.py index 3133907..e627cca 100644 --- a/Lib/unittest/case.py +++ b/Lib/unittest/case.py @@ -62,7 +62,7 @@ def skip(reason): Unconditionally skip a test. """ def decorator(test_item): - if not (isinstance(test_item, type) and issubclass(test_item, TestCase)): + if not isinstance(test_item, type): @functools.wraps(test_item) def skip_wrapper(*args, **kwargs): raise SkipTest(reason) diff --git a/Lib/unittest/test/test_skipping.py b/Lib/unittest/test/test_skipping.py index b592464..952240e 100644 --- a/Lib/unittest/test/test_skipping.py +++ b/Lib/unittest/test/test_skipping.py @@ -66,6 +66,21 @@ class Test_TestSkipping(unittest.TestCase): self.assertEqual(result.skipped, [(test, "testing")]) self.assertEqual(record, []) + def test_skip_non_unittest_class(self): + @unittest.skip("testing") + class Mixin: + def test_1(self): + record.append(1) + class Foo(Mixin, unittest.TestCase): + pass + record = [] + result = unittest.TestResult() + test = Foo("test_1") + suite = unittest.TestSuite([test]) + suite.run(result) + self.assertEqual(result.skipped, [(test, "testing")]) + self.assertEqual(record, []) + def test_expected_failure(self): class Foo(unittest.TestCase): @unittest.expectedFailure @@ -56,6 +56,9 @@ Core and Builtins Library ------- +- Issue #14664: It is now possible to use @unittest.skip{If,Unless} on a + test class that doesn't inherit from TestCase (i.e. a mixin). + - Issue #14160: TarFile.extractfile() failed to resolve symbolic links when the links were not located in an archive subdirectory. |