-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_without_django_loaded.py
117 lines (91 loc) · 2.36 KB
/
test_without_django_loaded.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
import pytest
@pytest.fixture
def no_ds(monkeypatch) -> None:
"""Ensure DJANGO_SETTINGS_MODULE is unset"""
monkeypatch.delenv("DJANGO_SETTINGS_MODULE")
pytestmark = pytest.mark.usefixtures("no_ds")
def test_no_ds(testdir) -> None:
testdir.makepyfile(
"""
import os
def test_env():
assert 'DJANGO_SETTINGS_MODULE' not in os.environ
def test_cfg(pytestconfig):
assert pytestconfig.option.ds is None
"""
)
r = testdir.runpytest_subprocess()
assert r.ret == 0
def test_database(testdir) -> None:
testdir.makepyfile(
"""
import pytest
@pytest.mark.django_db
def test_mark():
assert 0
@pytest.mark.django_db(transaction=True)
def test_mark_trans():
assert 0
def test_db(db):
assert 0
def test_transactional_db(transactional_db):
assert 0
"""
)
r = testdir.runpytest_subprocess()
assert r.ret == 0
r.stdout.fnmatch_lines(["*4 skipped*"])
def test_client(testdir) -> None:
testdir.makepyfile(
"""
def test_client(client):
assert 0
def test_admin_client(admin_client):
assert 0
"""
)
r = testdir.runpytest_subprocess()
assert r.ret == 0
r.stdout.fnmatch_lines(["*2 skipped*"])
def test_rf(testdir) -> None:
testdir.makepyfile(
"""
def test_rf(rf):
assert 0
"""
)
r = testdir.runpytest_subprocess()
assert r.ret == 0
r.stdout.fnmatch_lines(["*1 skipped*"])
def test_settings(testdir) -> None:
testdir.makepyfile(
"""
def test_settings(settings):
assert 0
"""
)
r = testdir.runpytest_subprocess()
assert r.ret == 0
r.stdout.fnmatch_lines(["*1 skipped*"])
def test_live_server(testdir) -> None:
testdir.makepyfile(
"""
def test_live_server(live_server):
assert 0
"""
)
r = testdir.runpytest_subprocess()
assert r.ret == 0
r.stdout.fnmatch_lines(["*1 skipped*"])
def test_urls_mark(testdir) -> None:
testdir.makepyfile(
"""
import pytest
@pytest.mark.urls('foo.bar')
def test_urls():
assert 0
"""
)
r = testdir.runpytest_subprocess()
assert r.ret == 0
r.stdout.fnmatch_lines(["*1 skipped*"])