summaryrefslogtreecommitdiffstats
path: root/Lib/unittest/__init__.py
diff options
context:
space:
mode:
authorRobert Collins <rbtcollins@hp.com>2014-11-04 14:09:01 (GMT)
committerRobert Collins <rbtcollins@hp.com>2014-11-04 14:09:01 (GMT)
commitbf2bda3c9704181cebb6163f5eacd5ad4e1c15f4 (patch)
tree1f2e15056fc7e7bd965dd5b043183bc575d28f62 /Lib/unittest/__init__.py
parentd39e199a0d49504583c5672252f653fc01837e32 (diff)
downloadcpython-bf2bda3c9704181cebb6163f5eacd5ad4e1c15f4.zip
cpython-bf2bda3c9704181cebb6163f5eacd5ad4e1c15f4.tar.gz
cpython-bf2bda3c9704181cebb6163f5eacd5ad4e1c15f4.tar.bz2
Close #22457: Honour load_tests in the start_dir of discovery.
We were not honouring load_tests in a package/__init__.py when that was the start_dir parameter, though we do when it is a child package. The fix required a little care since it introduces the possibility of infinite recursion.
Diffstat (limited to 'Lib/unittest/__init__.py')
-rw-r--r--Lib/unittest/__init__.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/Lib/unittest/__init__.py b/Lib/unittest/__init__.py
index a5d50af..f6d7ae2 100644
--- a/Lib/unittest/__init__.py
+++ b/Lib/unittest/__init__.py
@@ -67,3 +67,12 @@ from .signals import installHandler, registerResult, removeResult, removeHandler
# deprecated
_TextTestResult = TextTestResult
+
+# There are no tests here, so don't try to run anything discovered from
+# introspecting the symbols (e.g. FunctionTestCase). Instead, all our
+# tests come from within unittest.test.
+def load_tests(loader, tests, pattern):
+ import os.path
+ # top level directory cached on loader instance
+ this_dir = os.path.dirname(__file__)
+ return loader.discover(start_dir=this_dir, pattern=pattern)