Skip to content

Commit fd1e63c

Browse files
authored
fix: misc test fixes (#5450)
1 parent fd36ec3 commit fd1e63c

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

api/conftest.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,11 @@ def fs(fs: FakeFilesystem) -> FakeFilesystem:
148148
"""
149149
app_path = os.path.dirname(os.path.abspath(__file__))
150150
site_packages = site.getsitepackages() # Allow files within dependencies
151-
fs.add_real_paths([*site_packages, app_path])
151+
paths_to_add = [app_path]
152+
for site_package_path in site_packages:
153+
if not site_package_path.startswith(app_path):
154+
paths_to_add.append(site_package_path)
155+
fs.add_real_paths(paths_to_add)
152156
return fs
153157

154158

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,25 @@
11
import pytest
2+
from django.conf import settings
23
from django.core.management import CommandError, call_command
34

5+
DATABASES_LIST = list(settings.DATABASES.keys())
6+
47

58
def test_makemigrations_without_name_raises_error() -> None:
69
with pytest.raises(CommandError, match="--name/-n is a required argument"):
710
call_command("makemigrations")
811

912

10-
@pytest.mark.django_db(databases=["default", "analytics"])
13+
@pytest.mark.django_db(databases=DATABASES_LIST)
1114
def test_makemigrations_with_check_changes_runs_without_error() -> None:
1215
call_command("makemigrations", check_changes=True)
1316

1417

15-
@pytest.mark.django_db(databases=["default", "analytics"])
18+
@pytest.mark.django_db(databases=DATABASES_LIST)
1619
def test_makemigrations_with_dry_run_runs_without_error() -> None:
1720
call_command("makemigrations", dry_run=True)
1821

1922

20-
@pytest.mark.django_db(databases=["default", "analytics"])
23+
@pytest.mark.django_db(databases=DATABASES_LIST)
2124
def test_makemigrations_with_name_runs_without_error() -> None:
2225
call_command("makemigrations", name="some_useful_name")

0 commit comments

Comments
 (0)