mirror of
https://github.com/python/cpython.git
synced 2025-11-02 11:08:57 +00:00
Issue #19013: add a __main__ to unittest.test to ease CLI invocation
This commit is contained in:
parent
356bdeb0a1
commit
e1ba8df182
1 changed files with 18 additions and 0 deletions
18
Lib/unittest/test/__main__.py
Normal file
18
Lib/unittest/test/__main__.py
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
import os
|
||||||
|
import unittest
|
||||||
|
|
||||||
|
|
||||||
|
def load_tests(loader, standard_tests, pattern):
|
||||||
|
# top level directory cached on loader instance
|
||||||
|
this_dir = os.path.dirname(__file__)
|
||||||
|
pattern = pattern or "test_*.py"
|
||||||
|
# We are inside unittest.test, so the top-level is two notches up
|
||||||
|
top_level_dir = os.path.dirname(os.path.dirname(this_dir))
|
||||||
|
package_tests = loader.discover(start_dir=this_dir, pattern=pattern,
|
||||||
|
top_level_dir=top_level_dir)
|
||||||
|
standard_tests.addTests(package_tests)
|
||||||
|
return standard_tests
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
unittest.main()
|
||||||
Loading…
Add table
Add a link
Reference in a new issue