[Python-checkins] cpython: Issue #19013: add a __main__ to unittest.test.testmock to ease CLI invocation
antoine.pitrou
python-checkins at python.org
Sat Sep 14 00:39:22 CEST 2013
http://hg.python.org/cpython/rev/c2b926c0d0c2
changeset: 85691:c2b926c0d0c2
user: Antoine Pitrou <solipsis at pitrou.net>
date: Sat Sep 14 00:39:15 2013 +0200
summary:
Issue #19013: add a __main__ to unittest.test.testmock to ease CLI invocation
files:
Lib/unittest/test/testmock/__main__.py | 18 ++++++++++++++
1 files changed, 18 insertions(+), 0 deletions(-)
diff --git a/Lib/unittest/test/testmock/__main__.py b/Lib/unittest/test/testmock/__main__.py
new file mode 100644
--- /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()
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list