Skip to content

Commit c0090a9

Browse files
committed
Call runpytest_subprocess explicitly for pytest 2.7.x compatibility
1 parent 0e01f05 commit c0090a9

9 files changed

+57
-57
lines changed

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[pytest]
22
# --strict: warnings become errors.
33
# -r fEsxXw: show extra test summary info for everything.
4-
addopts = --ignore lib/ --ignore build/ --ignore include/ --ignore local/ --ignore src/ --strict -r fEsxXw --runpytest=subprocess
4+
addopts = --ignore lib/ --ignore build/ --ignore include/ --ignore local/ --ignore src/ --strict -r fEsxXw
55
DJANGO_SETTINGS_MODULE = pytest_django_test.settings_sqlite_file
66

77
[wheel]

tests/test_database.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ def test_db_access_3(self):
193193
Item.objects.count() == 1
194194
''')
195195

196-
result = django_testdir.runpytest('-v', '--reuse-db')
196+
result = django_testdir.runpytest_subprocess('-v', '--reuse-db')
197197
result.stdout.fnmatch_lines([
198198
"*test_db_access_1 ERROR*",
199199
"*test_db_access_2 FAILED*",

tests/test_db_setup.py

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def test_db_can_be_accessed():
2323
assert Item.objects.count() == 0
2424
''')
2525

26-
result = django_testdir.runpytest('-v', '--reuse-db')
26+
result = django_testdir.runpytest_subprocess('-v', '--reuse-db')
2727
assert result.ret == 0
2828
result.stdout.fnmatch_lines([
2929
"*test_db_can_be_accessed PASSED*",
@@ -55,7 +55,7 @@ def test_db_can_be_accessed():
5555

5656
# Do not pass in --create-db to make sure it is created when it
5757
# does not exist
58-
result_first = django_testdir.runpytest('-v', '--reuse-db')
58+
result_first = django_testdir.runpytest_subprocess('-v', '--reuse-db')
5959
assert result_first.ret == 0
6060

6161
result_first.stdout.fnmatch_lines([
@@ -66,7 +66,7 @@ def test_db_can_be_accessed():
6666
mark_database()
6767
assert mark_exists()
6868

69-
result_second = django_testdir.runpytest('-v', '--reuse-db')
69+
result_second = django_testdir.runpytest_subprocess('-v', '--reuse-db')
7070
assert result_second.ret == 0
7171
result_second.stdout.fnmatch_lines([
7272
"*test_db_can_be_accessed PASSED*",
@@ -75,7 +75,7 @@ def test_db_can_be_accessed():
7575
# Make sure the database has not been re-created
7676
assert mark_exists()
7777

78-
result_third = django_testdir.runpytest('-v', '--reuse-db', '--create-db')
78+
result_third = django_testdir.runpytest_subprocess('-v', '--reuse-db', '--create-db')
7979
assert result_third.ret == 0
8080
result_third.stdout.fnmatch_lines([
8181
"*test_db_can_be_accessed PASSED*",
@@ -119,7 +119,7 @@ def test_a():
119119
assert conn.settings_dict['NAME'] == '%s'
120120
''' % (self.db_name_17, self.db_name_before_17))
121121

122-
result = django_testdir.runpytest('--tb=short', '-v')
122+
result = django_testdir.runpytest_subprocess('--tb=short', '-v')
123123
assert result.ret == 0
124124
result.stdout.fnmatch_lines(['*test_a*PASSED*'])
125125

@@ -164,7 +164,7 @@ def test_d(settings):
164164
_check(settings)
165165
''')
166166

167-
result = django_testdir.runpytest('-vv', '-n2', '-s', '--reuse-db')
167+
result = django_testdir.runpytest_subprocess('-vv', '-n2', '-s', '--reuse-db')
168168
assert result.ret == 0
169169
result.stdout.fnmatch_lines(['*PASSED*test_a*'])
170170
result.stdout.fnmatch_lines(['*PASSED*test_b*'])
@@ -174,14 +174,14 @@ def test_d(settings):
174174
assert db_exists('gw0')
175175
assert db_exists('gw1')
176176

177-
result = django_testdir.runpytest('-vv', '-n2', '-s', '--reuse-db')
177+
result = django_testdir.runpytest_subprocess('-vv', '-n2', '-s', '--reuse-db')
178178
assert result.ret == 0
179179
result.stdout.fnmatch_lines(['*PASSED*test_a*'])
180180
result.stdout.fnmatch_lines(['*PASSED*test_b*'])
181181
result.stdout.fnmatch_lines(['*PASSED*test_c*'])
182182
result.stdout.fnmatch_lines(['*PASSED*test_d*'])
183183

184-
result = django_testdir.runpytest('-vv', '-n2', '-s', '--reuse-db',
184+
result = django_testdir.runpytest_subprocess('-vv', '-n2', '-s', '--reuse-db',
185185
'--create-db')
186186
assert result.ret == 0
187187
result.stdout.fnmatch_lines(['*PASSED*test_a*'])
@@ -213,7 +213,7 @@ def test_a():
213213
assert conn.creation._get_test_db_name() == ':memory:'
214214
''')
215215

216-
result = django_testdir.runpytest('--tb=short', '-vv', '-n1')
216+
result = django_testdir.runpytest_subprocess('--tb=short', '-vv', '-n1')
217217
assert result.ret == 0
218218
result.stdout.fnmatch_lines(['*PASSED*test_a*'])
219219

@@ -234,7 +234,7 @@ def test_inner_south():
234234
== ["mark_initial_data"]
235235
''')
236236

237-
result = django_testdir_initial.runpytest('--tb=short', '-v')
237+
result = django_testdir_initial.runpytest_subprocess('--tb=short', '-v')
238238
assert result.ret == 0
239239
result.stdout.fnmatch_lines(['*test_inner_south*PASSED*'])
240240

@@ -267,7 +267,7 @@ def test_inner_south():
267267
== ["mark_initial_data"]
268268
''')
269269

270-
result = django_testdir_initial.runpytest('--tb=short', '-v', '-s')
270+
result = django_testdir_initial.runpytest_subprocess('--tb=short', '-v', '-s')
271271
result.stdout.fnmatch_lines_random([
272272
"tpkg/test_the_test.py::test_inner_south*",
273273
"*PASSED*",
@@ -297,7 +297,7 @@ def test_inner_south():
297297
''')
298298
django_testdir_initial.mkpydir('tpkg/app/south_migrations')
299299

300-
result = django_testdir_initial.runpytest('--tb=short', '-v', '-s')
300+
result = django_testdir_initial.runpytest_subprocess('--tb=short', '-v', '-s')
301301
assert result.ret != 0
302302
# Can be OperationalError or DatabaseError (Django 1.4).
303303
result.stdout.fnmatch_lines([
@@ -324,7 +324,7 @@ def test_inner_south():
324324

325325
testdir.create_initial_south_migration()
326326

327-
result = testdir.runpytest('--tb=short', '-v', '-s')
327+
result = testdir.runpytest_subprocess('--tb=short', '-v', '-s')
328328
assert result.ret == 0
329329
result.stdout.fnmatch_lines(['*mark_south_migration_forwards*'])
330330

@@ -346,7 +346,7 @@ def test_inner_south():
346346
pass
347347
''')
348348

349-
result = django_testdir_initial.runpytest('--tb=short', '-v', '-s')
349+
result = django_testdir_initial.runpytest_subprocess('--tb=short', '-v', '-s')
350350
assert result.ret == 0
351351
result.stdout.fnmatch_lines(['*PASSED*'])
352352
assert 'mark_south_migration_forwards' not in result.stdout.str()
@@ -377,7 +377,7 @@ class Migration(SchemaMigration):
377377
def forwards(self, orm):
378378
print("mark_south_migration_forwards")
379379
""", 'south_migrations/0001_initial.py')
380-
result = testdir.runpytest('--tb=short', '-v', '-s')
380+
result = testdir.runpytest_subprocess('--tb=short', '-v', '-s')
381381
assert result.ret == 0
382382
result.stdout.fnmatch_lines(['*mark_south_migration_forwards*'])
383383

@@ -404,7 +404,7 @@ def test_inner_south():
404404
p.write('raise Exception("This should not get imported.")',
405405
ensure=True)
406406

407-
result = testdir.runpytest('--tb=short', '-v', '-s')
407+
result = testdir.runpytest_subprocess('--tb=short', '-v', '-s')
408408
assert result.ret == 0
409409
result.stdout.fnmatch_lines_random([
410410
"tpkg/test_the_test.py::test_inner_south*",
@@ -440,7 +440,7 @@ def test_inner_south():
440440
[pytest]
441441
python_files=*.py""", 'pytest.ini')
442442

443-
result = testdir.runpytest('--tb=short', '-v', '-s', '-c', pytest_ini)
443+
result = testdir.runpytest_subprocess('--tb=short', '-v', '-s', '-c', pytest_ini)
444444
assert result.ret == 0
445445
result.stdout.fnmatch_lines_random([
446446
"tpkg/test.py::test_inner_south*",
@@ -469,7 +469,7 @@ def test_inner_migrations():
469469
p.write('raise Exception("This should not get imported.")',
470470
ensure=True)
471471

472-
result = testdir.runpytest('--nomigrations', '--tb=short', '-v')
472+
result = testdir.runpytest_subprocess('--nomigrations', '--tb=short', '-v')
473473
assert result.ret == 0
474474
result.stdout.fnmatch_lines(['*test_inner_migrations*PASSED*'])
475475

@@ -515,6 +515,6 @@ class Migration(migrations.Migration):
515515
),
516516
]
517517
""", 'migrations/0001_initial.py')
518-
result = testdir.runpytest('--tb=short', '-v', '-s')
518+
result = testdir.runpytest_subprocess('--tb=short', '-v', '-s')
519519
assert result.ret == 0
520520
result.stdout.fnmatch_lines(['*mark_migrations_run*'])

tests/test_django_settings_module.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def test_ds_env(testdir, monkeypatch):
3030
def test_settings():
3131
assert os.environ['DJANGO_SETTINGS_MODULE'] == 'tpkg.settings_env'
3232
""")
33-
result = testdir.runpytest()
33+
result = testdir.runpytest_subprocess()
3434
result.stdout.fnmatch_lines(['*1 passed*'])
3535
assert result.ret == 0
3636

@@ -51,7 +51,7 @@ def test_ds_ini(testdir, monkeypatch):
5151
def test_ds():
5252
assert os.environ['DJANGO_SETTINGS_MODULE'] == 'tpkg.settings_ini'
5353
""")
54-
result = testdir.runpytest()
54+
result = testdir.runpytest_subprocess()
5555
result.stdout.fnmatch_lines(['*1 passed*'])
5656
assert result.ret == 0
5757

@@ -71,7 +71,7 @@ def test_ds_option(testdir, monkeypatch):
7171
def test_ds():
7272
assert os.environ['DJANGO_SETTINGS_MODULE'] == 'tpkg.settings_opt'
7373
""")
74-
result = testdir.runpytest('--ds=tpkg.settings_opt')
74+
result = testdir.runpytest_subprocess('--ds=tpkg.settings_opt')
7575
result.stdout.fnmatch_lines(['*1 passed*'])
7676
assert result.ret == 0
7777

@@ -83,7 +83,7 @@ def test_ds_non_existent(testdir, monkeypatch):
8383
"""
8484
monkeypatch.setenv('DJANGO_SETTINGS_MODULE', 'DOES_NOT_EXIST')
8585
testdir.makepyfile('def test_ds(): pass')
86-
result = testdir.runpytest()
86+
result = testdir.runpytest_subprocess()
8787
result.stderr.fnmatch_lines(["*ImportError:*DOES_NOT_EXIST*"])
8888
assert result.ret != 0
8989

@@ -97,7 +97,7 @@ def test_ds_after_user_conftest(testdir, monkeypatch):
9797
testdir.makepyfile('def test_ds(): pass')
9898
testdir.makepyfile(settings_after_conftest="SECRET_KEY='secret'")
9999
# testdir.makeconftest("import sys; print(sys.path)")
100-
result = testdir.runpytest('-v')
100+
result = testdir.runpytest_subprocess('-v')
101101
result.stdout.fnmatch_lines(['*1 passed*'])
102102
assert result.ret == 0
103103

@@ -119,7 +119,7 @@ def pytest_configure():
119119
os.environ.setdefault('DJANGO_SETTINGS_MODULE',
120120
'tpkg.settings_ds')
121121
""")
122-
r = testdir.runpytest()
122+
r = testdir.runpytest_subprocess()
123123
assert r.ret == 0
124124

125125

@@ -205,7 +205,7 @@ def test_access_to_setting():
205205
def test_user_count():
206206
assert User.objects.count() == 0
207207
""")
208-
r = testdir.runpytest()
208+
r = testdir.runpytest_subprocess()
209209
assert r.ret == 0
210210

211211

@@ -219,7 +219,7 @@ def test_django_not_loaded_without_settings(testdir, monkeypatch):
219219
def test_settings():
220220
assert 'django' not in sys.modules
221221
""")
222-
result = testdir.runpytest()
222+
result = testdir.runpytest_subprocess()
223223
result.stdout.fnmatch_lines(['*1 passed*'])
224224
assert result.ret == 0
225225

@@ -247,7 +247,7 @@ def test_debug_is_false():
247247
assert settings.DEBUG is False
248248
""")
249249

250-
r = testdir.runpytest()
250+
r = testdir.runpytest_subprocess()
251251
assert r.ret == 0
252252

253253

@@ -288,7 +288,7 @@ def test_anything():
288288
apps._lock.locked(), apps.ready))
289289
""")
290290

291-
result = django_testdir.runpytest('-s', '--tb=line')
291+
result = django_testdir.runpytest_subprocess('-s', '--tb=line')
292292
result.stdout.fnmatch_lines(['*IMPORT: populating=True,ready=False*'])
293293
result.stdout.fnmatch_lines(['*READY(): populating=True*'])
294294
result.stdout.fnmatch_lines(['*TEST: populating=False,ready=True*'])
@@ -316,5 +316,5 @@ def test_env():
316316
def test_cfg(pytestconfig):
317317
assert pytestconfig.option.ds is None
318318
""")
319-
r = testdir.runpytest('-s')
319+
r = testdir.runpytest_subprocess('-s')
320320
assert r.ret == 0

tests/test_environment.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def test_for_invalid_template(client):
6565
def test_ignore(client):
6666
client.get('/invalid_template/')
6767
''')
68-
result = django_testdir.runpytest('-s', '--fail-on-template-vars')
68+
result = django_testdir.runpytest_subprocess('-s', '--fail-on-template-vars')
6969
result.stdout.fnmatch_lines_random([
7070
"tpkg/test_the_test.py F.",
7171
"Undefined template variable 'invalid_var' in 'invalid_template.html'",
@@ -109,7 +109,7 @@ def test_for_invalid_template(client):
109109
def test_ignore(client):
110110
client.get('/invalid_template/')
111111
''')
112-
result = django_testdir.runpytest('-s')
112+
result = django_testdir.runpytest_subprocess('-s')
113113
result.stdout.fnmatch_lines_random([
114114
"tpkg/test_the_test.py ..",
115115
])
@@ -155,35 +155,35 @@ def test_inner_testrunner():
155155

156156
def test_default(self, testdir):
157157
"""Not verbose by default."""
158-
result = testdir.runpytest('-s')
158+
result = testdir.runpytest_subprocess('-s')
159159
result.stdout.fnmatch_lines([
160160
"tpkg/test_the_test.py ."])
161161

162162
def test_vq_verbosity_0(self, testdir):
163163
"""-v and -q results in verbosity 0."""
164-
result = testdir.runpytest('-s', '-v', '-q')
164+
result = testdir.runpytest_subprocess('-s', '-v', '-q')
165165
result.stdout.fnmatch_lines([
166166
"tpkg/test_the_test.py ."])
167167

168168
def test_verbose_with_v(self, testdir):
169169
"""Verbose output with '-v'."""
170-
result = testdir.runpytest('-s', '-v')
170+
result = testdir.runpytest_subprocess('-s', '-v')
171171
result.stdout.fnmatch_lines_random([
172172
"tpkg/test_the_test.py:*",
173173
"*PASSED*",
174174
"*Destroying test database for alias 'default'...*"])
175175

176176
def test_more_verbose_with_vv(self, testdir):
177177
"""More verbose output with '-v -v'."""
178-
result = testdir.runpytest('-s', '-v', '-v')
178+
result = testdir.runpytest_subprocess('-s', '-v', '-v')
179179
result.stdout.fnmatch_lines([
180180
"tpkg/test_the_test.py:*Creating test database for alias*",
181181
"*Creating table app_item*",
182182
"*PASSED*Destroying test database for alias 'default' ('*')...*"])
183183

184184
def test_more_verbose_with_vv_and_reusedb(self, testdir):
185185
"""More verbose output with '-v -v', and --reuse-db."""
186-
result = testdir.runpytest('-s', '-v', '-v', '--reuse-db')
186+
result = testdir.runpytest_subprocess('-s', '-v', '-v', '--reuse-db')
187187
result.stdout.fnmatch_lines([
188188
"tpkg/test_the_test.py:*Creating test database for alias*",
189189
"*PASSED*"])

tests/test_fixtures.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ def test_a(self, live_server, settings):
182182
live_server + '/static/a_file.txt').read()
183183
assert force_text(response_data) == 'bla\\n'
184184
""")
185-
result = django_testdir.runpytest('--tb=short', '-v')
185+
result = django_testdir.runpytest_subprocess('--tb=short', '-v')
186186
result.stdout.fnmatch_lines(['*test_a*PASSED*'])
187187
assert result.ret == 0
188188

@@ -296,6 +296,6 @@ class Migration(migrations.Migration):
296296
]
297297
""", 'migrations/0001_initial.py') # noqa
298298

299-
result = django_testdir.runpytest('-s')
299+
result = django_testdir.runpytest_subprocess('-s')
300300
result.stdout.fnmatch_lines(['*1 passed*'])
301301
assert result.ret == 0

0 commit comments

Comments
 (0)