From 4b3c58c8a0b0c041854e80e9a01aeb5d77872a05 Mon Sep 17 00:00:00 2001 From: Antoine Pitrou Date: Sat, 14 Sep 2013 00:39:15 +0200 Subject: [PATCH] Issue #19013: add a __main__ to unittest.test.testmock to ease CLI invocation --- Lib/unittest/test/testmock/__main__.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 Lib/unittest/test/testmock/__main__.py diff --git a/Lib/unittest/test/testmock/__main__.py b/Lib/unittest/test/testmock/__main__.py new file mode 100644 index 0000000000..24e1933a8e --- /dev/null +++ b/Lib/unittest/test/testmock/__main__.py @@ -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(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() -- 2.50.1