Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4b3c58c

Browse files
committed
Issue #19013: add a __main__ to unittest.test.testmock to ease CLI invocation
1 parent e1ba8df commit 4b3c58c

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import os
2+
import unittest
3+
4+
5+
def load_tests(loader, standard_tests, pattern):
6+
# top level directory cached on loader instance
7+
this_dir = os.path.dirname(__file__)
8+
pattern = pattern or "test*.py"
9+
# We are inside unittest.test, so the top-level is two notches up
10+
top_level_dir = os.path.dirname(os.path.dirname(os.path.dirname(this_dir)))
11+
package_tests = loader.discover(start_dir=this_dir, pattern=pattern,
12+
top_level_dir=top_level_dir)
13+
standard_tests.addTests(package_tests)
14+
return standard_tests
15+
16+
17+
if __name__ == '__main__':
18+
unittest.main()

0 commit comments

Comments
 (0)