diff -r 44253ce374fc Lib/unittest/loader.py --- a/Lib/unittest/loader.py Mon Jun 22 12:31:24 2015 -0400 +++ b/Lib/unittest/loader.py Tue Jun 23 22:25:28 2015 +0800 @@ -417,9 +417,15 @@ """ basename = os.path.basename(full_path) if os.path.isfile(full_path): - if not VALID_MODULE_NAME.match(basename): - # valid Python identifiers only - return None, False + root, ext = os.path.splitext(basename) + try: + if not (ext == '.py' and root.isidentifier()): + # valid Python identifiers only + return None, False + except: + if not VALID_MODULE_NAME.match(basename): + # valid Python identifiers only + return None, False if not self._match_path(basename, full_path, pattern): return None, False # if the test file matches, load it