File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change 1313import warnings
1414from pathlib import Path
1515
16+ import django_mongodb_backend
17+
1618try :
1719 import django
1820except ImportError as e :
5759
5860RUNTESTS_DIR = os .path .abspath (os .path .dirname (__file__ ))
5961
62+ MONGODB_TEST_DIR = Path (django_mongodb_backend .__file__ ).parent .parent / "tests"
63+ sys .path .append (str (MONGODB_TEST_DIR ))
64+
6065TEMPLATE_DIR = os .path .join (RUNTESTS_DIR , "templates" )
6166
6267# Create a specific subdirectory for the duration of the test suite.
@@ -139,6 +144,21 @@ def get_test_modules(gis_enabled):
139144 test_module = dirname + "." + test_module
140145 yield test_module
141146
147+ # Discover tests in django_mongodb_backend/tests.
148+ dirpath = os .path .join (MONGODB_TEST_DIR , dirname )
149+ with os .scandir (dirpath ) as entries :
150+ for f in entries :
151+ if (
152+ "." in f .name
153+ or f .is_file ()
154+ or not os .path .exists (os .path .join (f .path , "__init__.py" ))
155+ ):
156+ continue
157+ test_module = f .name
158+ if dirname :
159+ test_module = dirname + "." + test_module
160+ yield test_module
161+
142162
143163def get_label_module (label ):
144164 """Return the top-level module part for a test label."""
You can’t perform that action at this time.
0 commit comments