Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow runtests.py to discover tests in django_mongodb/tests #9

Merged
merged 1 commit into from
Oct 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions tests/runtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
import warnings
from pathlib import Path

import django_mongodb

try:
import django
except ImportError as e:
Expand Down Expand Up @@ -60,6 +62,9 @@

RUNTESTS_DIR = os.path.abspath(os.path.dirname(__file__))

MONGODB_TEST_DIR = Path(django_mongodb.__file__).parent.parent / "tests"
sys.path.append(str(MONGODB_TEST_DIR))

TEMPLATE_DIR = os.path.join(RUNTESTS_DIR, "templates")

# Create a specific subdirectory for the duration of the test suite.
Expand Down Expand Up @@ -142,6 +147,21 @@ def get_test_modules(gis_enabled):
test_module = dirname + "." + test_module
yield test_module

# Discover tests in django_mongodb/tests.
dirpath = os.path.join(MONGODB_TEST_DIR, dirname)
with os.scandir(dirpath) as entries:
for f in entries:
if (
"." in f.name
or f.is_file()
or not os.path.exists(os.path.join(f.path, "__init__.py"))
):
continue
test_module = f.name
if dirname:
test_module = dirname + "." + test_module
yield test_module


def get_label_module(label):
"""Return the top-level module part for a test label."""
Expand Down
Loading