Skip to content

Commit 2b5b197

Browse files
authored
Update test_environment.py
1 parent b9dee6a commit 2b5b197

File tree

1 file changed

+2
-20
lines changed

1 file changed

+2
-20
lines changed

tests/test_environment.py

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -21,26 +21,8 @@
2121
@pytest.mark.django_project(
2222
extra_settings="""
2323
EMAIL_BACKEND = "django.core.mail.backends.dummy.EmailBackend"
24-
import unittest.mock
25-
from types import SimpleNamespace
26-
27-
def setup_test_environment(*a, **k):
28-
if hasattr(_TestState, "saved_data"):
29-
# Executing this function twice would overwrite the saved values.
30-
raise RuntimeError(
31-
"setup_test_environment() was already called and can't be called "
32-
"again without first calling teardown_test_environment()."
33-
)
34-
35-
saved_data = SimpleNamespace()
36-
_TestState.saved_data = saved_data
37-
saved_data.allowed_hosts = []
38-
saved_data.debug = False
39-
saved_data.email_backend = None
40-
saved_data.template_render = None
4124
42-
unittest.mock.patch("django.test.utils.setup_test_environment", setup_test_environment).start()
43-
from django.test.utils import _TestState
25+
unittest.mock.patch("pytest_django.lazy_django.django_settings_is_configured", lambda: False).start()
4426
""",
4527
)
4628
def test_mail_auto_fixture(django_pytester: DjangoPytester) -> None:
@@ -50,7 +32,7 @@ def test_bad_mail():
5032
pass
5133
"""
5234
)
53-
result = django_pytester.runpytest_subprocess("-s", "-vv")
35+
result = django_pytester.runpytest_subprocess("-s")
5436
print("\n".join([*result.outlines, *result.errlines]))
5537
assert "1 passed" in "\n".join([*result.outlines, *result.errlines])
5638

0 commit comments

Comments
 (0)