Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Lib/unittest/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,9 @@ def shouldIncludeMethod(attrname):
testFunc = getattr(testCaseClass, attrname)
if not callable(testFunc):
return False
fullName = '%s.%s' % (testCaseClass.__module__, testFunc.__qualname__)
fullName = f'%s.%s.%s' % (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The f-string is superfluous here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch, it didn't wrap well as an f string, forgot to remove the f.

testCaseClass.__module__, testCaseClass.__qualname__, attrname
)
return self.testNamePatterns is None or \
any(fnmatchcase(fullName, pattern) for pattern in self.testNamePatterns)
testFnNames = list(filter(shouldIncludeMethod, dir(testCaseClass)))
Expand Down
16 changes: 16 additions & 0 deletions Lib/unittest/test/test_loader.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import functools
import sys
import types
import warnings
Expand Down Expand Up @@ -1575,5 +1576,20 @@ def test_suiteClass__default_value(self):
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()