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
17+
1618try :
1719 import django
1820except ImportError as e :
6062
6163RUNTESTS_DIR = os .path .abspath (os .path .dirname (__file__ ))
6264
65+ MONGODB_TEST_DIR = Path (django_mongodb .__file__ ).parent .parent / "tests"
66+ sys .path .append (str (MONGODB_TEST_DIR ))
67+
6368TEMPLATE_DIR = os .path .join (RUNTESTS_DIR , "templates" )
6469
6570# Create a specific subdirectory for the duration of the test suite.
@@ -142,6 +147,21 @@ def get_test_modules(gis_enabled):
142147 test_module = dirname + "." + test_module
143148 yield test_module
144149
150+ # Discover tests in django_mongodb/tests.
151+ dirpath = os .path .join (MONGODB_TEST_DIR , dirname )
152+ with os .scandir (dirpath ) as entries :
153+ for f in entries :
154+ if (
155+ "." in f .name
156+ or f .is_file ()
157+ or not os .path .exists (os .path .join (f .path , "__init__.py" ))
158+ ):
159+ continue
160+ test_module = f .name
161+ if dirname :
162+ test_module = dirname + "." + test_module
163+ yield test_module
164+
145165
146166def get_label_module (label ):
147167 """Return the top-level module part for a test label."""
You can’t perform that action at this time.
0 commit comments