There was an error while loading. Please reload this page.
1 parent f6243ac commit fd628cfCopy full SHA for fd628cf
2 files changed
Lib/unittest/loader.py
@@ -229,7 +229,9 @@ def shouldIncludeMethod(attrname):
229
testFunc = getattr(testCaseClass, attrname)
230
if not callable(testFunc):
231
return False
232
- fullName = '%s.%s' % (testCaseClass.__module__, testFunc.__qualname__)
+ fullName = f'%s.%s.%s' % (
233
+ testCaseClass.__module__, testCaseClass.__qualname__, attrname
234
+ )
235
return self.testNamePatterns is None or \
236
any(fnmatchcase(fullName, pattern) for pattern in self.testNamePatterns)
237
testFnNames = list(filter(shouldIncludeMethod, dir(testCaseClass)))
Lib/unittest/test/test_loader.py
@@ -1,3 +1,4 @@
1
+import functools
2
import sys
3
import types
4
import warnings
@@ -1575,5 +1576,20 @@ def test_suiteClass__default_value(self):
1575
1576
self.assertIs(loader.suiteClass, unittest.TestSuite)
1577
1578
1579
+ def test_partial_functions(self):
1580
+ def noop(arg):
1581
+ pass
1582
+
1583
+ class Foo(unittest.TestCase):
1584
1585
1586
+ setattr(Foo, 'test_partial', functools.partial(noop, None))
1587
1588
+ loader = unittest.TestLoader()
1589
1590
+ test_names = ['test_partial']
1591
+ self.assertEqual(loader.getTestCaseNames(Foo), test_names)
1592
1593
1594
if __name__ == "__main__":
1595
unittest.main()
0 commit comments