diff options
| author | Jason Fried <me@jasonfried.info> | 2019-01-23 20:57:25 (GMT) |
|---|---|---|
| committer | Ćukasz Langa <lukasz@langa.pl> | 2019-01-23 20:57:25 (GMT) |
| commit | fd628cf5adaeee73eab579393cdff71c8f70cdf2 (patch) | |
| tree | 7695ac974b593adb2b24121f6a8476551e8ed5e4 /Lib/unittest/test/test_loader.py | |
| parent | f6243ac1e4828299fe5a8e943d7bd41cab1f34cd (diff) | |
| download | cpython-fd628cf5adaeee73eab579393cdff71c8f70cdf2.zip cpython-fd628cf5adaeee73eab579393cdff71c8f70cdf2.tar.gz cpython-fd628cf5adaeee73eab579393cdff71c8f70cdf2.tar.bz2 | |
bpo-35767: Fix unittest.loader to allow partials as test_functions (#11600)
Diffstat (limited to 'Lib/unittest/test/test_loader.py')
| -rw-r--r-- | Lib/unittest/test/test_loader.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/Lib/unittest/test/test_loader.py b/Lib/unittest/test/test_loader.py index bfd7229..bc54bf0 100644 --- a/Lib/unittest/test/test_loader.py +++ b/Lib/unittest/test/test_loader.py @@ -1,3 +1,4 @@ +import functools import sys import types import warnings @@ -1575,5 +1576,20 @@ class Test_TestLoader(unittest.TestCase): self.assertIs(loader.suiteClass, unittest.TestSuite) + def test_partial_functions(self): + def noop(arg): + pass + + class Foo(unittest.TestCase): + pass + + setattr(Foo, 'test_partial', functools.partial(noop, None)) + + loader = unittest.TestLoader() + + test_names = ['test_partial'] + self.assertEqual(loader.getTestCaseNames(Foo), test_names) + + if __name__ == "__main__": unittest.main() |
