66import mock
77import pytest
88
9+ from tests .conftest import DEFAULT_PYTEST_FLAGS
10+
911DUMMY_TEST_QUERY = """
1012 import pytest
1113
@@ -32,7 +34,9 @@ def test_fixture_is_invoked_when_marked(testdir):
3234 # Run a dummy test that performs queries
3335 # and triggers a counting of the query number
3436 testdir .makepyfile (test_file = DUMMY_TEST_QUERY )
35- results = testdir .runpytest ("--django-db-bench" , results_path )
37+ results = testdir .runpytest (
38+ * DEFAULT_PYTEST_FLAGS , "--django-db-bench" , results_path
39+ )
3640
3741 # Ensure the tests have passed
3842 results .assert_outcomes (1 , 0 , 0 )
@@ -56,7 +60,9 @@ def test_plugin_exports_nothing_if_empty(testdir):
5660 def test_nothing():
5761 pass
5862 """ )
59- results = testdir .runpytest ("--django-db-bench" , results_path )
63+ results = testdir .runpytest (
64+ * DEFAULT_PYTEST_FLAGS , "--django-db-bench" , results_path
65+ )
6066
6167 # Ensure the tests have passed
6268 results .assert_outcomes (1 , 0 , 0 )
@@ -80,7 +86,9 @@ def test_plugin_exports_results_even_when_test_fails(testdir):
8086 def test_failure():
8187 assert 0
8288 """ )
83- results = testdir .runpytest ("--django-db-bench" , results_path )
89+ results = testdir .runpytest (
90+ * DEFAULT_PYTEST_FLAGS , "--django-db-bench" , results_path
91+ )
8492
8593 # Ensure the tests have failed
8694 results .assert_outcomes (0 , 0 , 1 )
@@ -114,7 +122,9 @@ def fixture_with_db_queries():
114122 def test_with_side_effects(fixture_with_db_queries, count_queries):
115123 pass
116124 """ )
117- results = testdir .runpytest ("--django-db-bench" , results_path )
125+ results = testdir .runpytest (
126+ * DEFAULT_PYTEST_FLAGS , "--django-db-bench" , results_path
127+ )
118128
119129 # Ensure the tests have passed
120130 results .assert_outcomes (1 , 0 , 0 )
@@ -140,7 +150,9 @@ def test_plugin_marker_without_autouse_disabled(testdir):
140150 def test_without_autouse():
141151 pass
142152 """ )
143- results = testdir .runpytest ("--django-db-bench" , results_path )
153+ results = testdir .runpytest (
154+ * DEFAULT_PYTEST_FLAGS , "--django-db-bench" , results_path
155+ )
144156
145157 # Ensure the tests have passed
146158 results .assert_outcomes (1 , 0 , 0 )
@@ -159,7 +171,11 @@ def test_fixture_is_backing_up_old_results(testdir):
159171 testdir .makepyfile (test_file = DUMMY_TEST_QUERY )
160172
161173 results = testdir .runpytest (
162- "--django-db-bench" , results_path , "--django-backup-queries" , old_results_path
174+ * DEFAULT_PYTEST_FLAGS ,
175+ "--django-db-bench" ,
176+ results_path ,
177+ "--django-backup-queries" ,
178+ old_results_path ,
163179 )
164180
165181 # Ensure the tests have passed
@@ -177,7 +193,11 @@ def test_fixture_is_backing_up_old_results(testdir):
177193
178194 # Run again the tests
179195 results = testdir .runpytest (
180- "--django-db-bench" , results_path , "--django-backup-queries" , old_results_path
196+ * DEFAULT_PYTEST_FLAGS ,
197+ "--django-db-bench" ,
198+ results_path ,
199+ "--django-backup-queries" ,
200+ old_results_path ,
181201 )
182202
183203 # Ensure the tests have passed
@@ -211,7 +231,9 @@ def test_fixture_is_not_backing_up_if_not_asked_to(testdir):
211231 testdir .makepyfile (test_file = DUMMY_TEST_QUERY )
212232
213233 with mock .patch ("pytest_django_queries.plugin.create_backup" ) as mocked_backup :
214- results = testdir .runpytest ("--django-db-bench" , results_path )
234+ results = testdir .runpytest (
235+ * DEFAULT_PYTEST_FLAGS , "--django-db-bench" , results_path
236+ )
215237 assert mocked_backup .call_count == 0
216238
217239 # Ensure the tests have passed
@@ -232,7 +254,10 @@ def test_fixture_is_backing_up_old_results_to_default_path_if_no_path_provided(t
232254 from pytest_django_queries .plugin import DEFAULT_OLD_RESULT_FILENAME
233255
234256 results = testdir .runpytest (
235- "--django-db-bench" , results_path , "--django-backup-queries"
257+ * DEFAULT_PYTEST_FLAGS ,
258+ "--django-db-bench" ,
259+ results_path ,
260+ "--django-backup-queries" ,
236261 )
237262 mocked_backup .assert_called_with (str (results_path ), DEFAULT_OLD_RESULT_FILENAME )
238263
@@ -243,7 +268,7 @@ def test_fixture_is_backing_up_old_results_to_default_path_if_no_path_provided(t
243268
244269def test_marker_message (testdir ):
245270 """Ensure the custom markers configuration is added to pytest."""
246- result = testdir .runpytest ("--markers" )
271+ result = testdir .runpytest (* DEFAULT_PYTEST_FLAGS , "--markers" )
247272 result .stdout .fnmatch_lines (
248273 [
249274 "@pytest.mark.count_queries: "
@@ -254,7 +279,7 @@ def test_marker_message(testdir):
254279
255280def test_implements_custom_options (testdir ):
256281 """Ensure the custom options are added to pytest."""
257- result = testdir .runpytest ("--help" )
282+ result = testdir .runpytest (* DEFAULT_PYTEST_FLAGS , "--help" )
258283 result .stdout .fnmatch_lines (
259284 [
260285 "django-queries:" ,
@@ -286,7 +311,9 @@ def test_foo():
286311 cursor.execute("SELECT 1;")
287312 cursor.fetchone()""" )
288313
289- results = testdir .runpytest ("--django-db-bench" , results_path , script )
314+ results = testdir .runpytest (
315+ * DEFAULT_PYTEST_FLAGS , "--django-db-bench" , results_path , script
316+ )
290317
291318 # Ensure the tests have passed
292319 results .assert_outcomes (1 , 0 , 0 )
@@ -324,7 +351,9 @@ def test_foo(foo):
324351 # Append current test files into the temporary test directory in order
325352 # to have settings.py available for PyPi packages
326353 shutil .copytree (os .path .dirname (__file__ ), os .path .join (str (testdir ) + "/tests" ))
327- results = testdir .runpytest ("--django-db-bench" , results_path , "-n" , "5" , script )
354+ results = testdir .runpytest (
355+ * DEFAULT_PYTEST_FLAGS , "--django-db-bench" , results_path , "-n" , "5" , script
356+ )
328357
329358 # Ensure the tests have passed
330359 results .assert_outcomes (500 , 0 , 0 )
0 commit comments