@@ -89,16 +89,19 @@ def skip_if_no_async_generators():
89
89
@pytest .fixture
90
90
def cmd_opts (request ):
91
91
reactor = request .config .getoption ("reactor" , "default" )
92
- return ("--reactor={}" .format (reactor ),)
92
+ return (
93
+ sys .executable ,
94
+ "-m" ,
95
+ "pytest" ,
96
+ "-v" ,
97
+ "--reactor={}" .format (reactor ),
98
+ )
93
99
94
100
95
101
def test_inline_callbacks_in_pytest ():
96
102
assert hasattr (pytest , 'inlineCallbacks' )
97
103
98
104
99
- run_args = [sys .executable , "-m" , "pytest" , "-v" ]
100
-
101
-
102
105
@pytest .mark .parametrize (
103
106
'decorator, should_warn' ,
104
107
(
@@ -122,7 +125,7 @@ def f():
122
125
yield 42
123
126
""" .format (import_path = import_path , decorator = decorator )
124
127
testdir .makepyfile (test_file )
125
- rr = testdir .run (* run_args , * cmd_opts , timeout = timeout )
128
+ rr = testdir .run (* cmd_opts , timeout = timeout )
126
129
127
130
expected_outcomes = {"passed" : 1 }
128
131
if should_warn :
@@ -166,7 +169,7 @@ def test_succeed(foo):
166
169
pass
167
170
""" .format (import_path = import_path , function = function )
168
171
testdir .makepyfile (test_file )
169
- rr = testdir .run (* run_args , * cmd_opts , timeout = timeout )
172
+ rr = testdir .run (* cmd_opts , timeout = timeout )
170
173
171
174
expected_outcomes = {"passed" : 1 }
172
175
if should_warn :
@@ -191,7 +194,7 @@ def doit():
191
194
return d
192
195
"""
193
196
testdir .makepyfile (test_file )
194
- rr = testdir .run (* run_args , * cmd_opts , timeout = timeout )
197
+ rr = testdir .run (* cmd_opts , timeout = timeout )
195
198
assert_outcomes (rr , {"failed" : 1 })
196
199
197
200
@@ -205,7 +208,7 @@ def test_succeed():
205
208
return d
206
209
"""
207
210
testdir .makepyfile (test_file )
208
- rr = testdir .run (* run_args , * cmd_opts , timeout = timeout )
211
+ rr = testdir .run (* cmd_opts , timeout = timeout )
209
212
assert_outcomes (rr , {"passed" : 1 })
210
213
211
214
@@ -217,7 +220,7 @@ def test_succeed():
217
220
return 42
218
221
"""
219
222
testdir .makepyfile (test_file )
220
- rr = testdir .run (* run_args , * cmd_opts , timeout = timeout )
223
+ rr = testdir .run (* cmd_opts , timeout = timeout )
221
224
assert_outcomes (rr , {"passed" : 1 })
222
225
223
226
@@ -227,7 +230,7 @@ def test_more_fail():
227
230
raise RuntimeError("foo")
228
231
"""
229
232
testdir .makepyfile (test_file )
230
- rr = testdir .run (* run_args , * cmd_opts , timeout = timeout )
233
+ rr = testdir .run (* cmd_opts , timeout = timeout )
231
234
assert_outcomes (rr , {"failed" : 1 })
232
235
233
236
@@ -248,7 +251,7 @@ def test_succeed(foo):
248
251
raise RuntimeError("baz")
249
252
"""
250
253
testdir .makepyfile (test_file )
251
- rr = testdir .run (* run_args , * cmd_opts , timeout = timeout )
254
+ rr = testdir .run (* cmd_opts , timeout = timeout )
252
255
assert_outcomes (rr , {"passed" : 2 , "failed" : 1 })
253
256
254
257
@@ -270,7 +273,7 @@ async def test_succeed(foo):
270
273
raise RuntimeError("baz")
271
274
"""
272
275
testdir .makepyfile (test_file )
273
- rr = testdir .run (* run_args , * cmd_opts , timeout = timeout )
276
+ rr = testdir .run (* cmd_opts , timeout = timeout )
274
277
assert_outcomes (rr , {"passed" : 2 , "failed" : 1 })
275
278
276
279
@@ -290,7 +293,7 @@ def test_MAIN():
290
293
assert MAIN is greenlet.getcurrent()
291
294
"""
292
295
testdir .makepyfile (test_file )
293
- rr = testdir .run (* run_args , * cmd_opts , timeout = timeout )
296
+ rr = testdir .run (* cmd_opts , timeout = timeout )
294
297
assert_outcomes (rr , {"passed" : 1 })
295
298
296
299
@@ -315,7 +318,7 @@ def test_succeed(foo):
315
318
raise RuntimeError("baz")
316
319
"""
317
320
testdir .makepyfile (test_file )
318
- rr = testdir .run (* run_args , * cmd_opts , timeout = timeout )
321
+ rr = testdir .run (* cmd_opts , timeout = timeout )
319
322
assert_outcomes (rr , {"passed" : 2 , "failed" : 1 })
320
323
321
324
@@ -341,7 +344,7 @@ async def test_succeed(foo):
341
344
raise RuntimeError("baz")
342
345
"""
343
346
testdir .makepyfile (test_file )
344
- rr = testdir .run (* run_args , * cmd_opts , timeout = timeout )
347
+ rr = testdir .run (* cmd_opts , timeout = timeout )
345
348
assert_outcomes (rr , {"passed" : 2 , "failed" : 1 })
346
349
347
350
@@ -377,7 +380,7 @@ def test_succeed_blue(foo):
377
380
raise RuntimeError("baz")
378
381
"""
379
382
testdir .makepyfile (test_file )
380
- rr = testdir .run (* run_args , * cmd_opts , timeout = timeout )
383
+ rr = testdir .run (* cmd_opts , timeout = timeout )
381
384
assert_outcomes (rr , {"passed" : 2 , "failed" : 1 })
382
385
383
386
@@ -414,7 +417,7 @@ def test_succeed(this, that):
414
417
testdir .makepyfile (test_file )
415
418
# TODO: add a timeout, failure just hangs indefinitely for now
416
419
# https://github.com/pytest-dev/pytest/issues/4073
417
- rr = testdir .run (* run_args , * cmd_opts , timeout = timeout )
420
+ rr = testdir .run (* cmd_opts , timeout = timeout )
418
421
assert_outcomes (rr , {"passed" : 1 })
419
422
420
423
@@ -453,7 +456,7 @@ def test_succeed(foo):
453
456
raise RuntimeError("baz")
454
457
"""
455
458
testdir .makepyfile (test_file )
456
- rr = testdir .run (* run_args , * cmd_opts , timeout = timeout )
459
+ rr = testdir .run (* cmd_opts , timeout = timeout )
457
460
# TODO: this is getting super imprecise...
458
461
assert_outcomes (rr , {"passed" : 4 , "failed" : 1 , "errors" : 2 })
459
462
@@ -502,7 +505,7 @@ def test_second(foo):
502
505
check_me = 2
503
506
"""
504
507
testdir .makepyfile (test_file )
505
- rr = testdir .run (* run_args , * cmd_opts , timeout = timeout )
508
+ rr = testdir .run (* cmd_opts , timeout = timeout )
506
509
assert_outcomes (rr , {"passed" : 2 })
507
510
508
511
@@ -531,7 +534,7 @@ async def test_doublefour(doublefour):
531
534
assert doublefour == 8
532
535
"""
533
536
testdir .makepyfile (test_file )
534
- rr = testdir .run (* run_args , * cmd_opts , timeout = timeout )
537
+ rr = testdir .run (* cmd_opts , timeout = timeout )
535
538
assert_outcomes (rr , {"passed" : 2 })
536
539
537
540
@@ -560,7 +563,7 @@ async def test_doublefour(doublefour):
560
563
assert doublefour == 8
561
564
"""
562
565
testdir .makepyfile (test_file )
563
- rr = testdir .run (* run_args , * cmd_opts , timeout = timeout )
566
+ rr = testdir .run (* cmd_opts , timeout = timeout )
564
567
assert_outcomes (rr , {"passed" : 2 })
565
568
566
569
@@ -607,7 +610,7 @@ async def test_doubleincrement(doubleincrement):
607
610
assert (first, second) == (0, 2)
608
611
""" .format (maybe_async = maybe_async , maybe_await = maybe_await )
609
612
testdir .makepyfile (test_file )
610
- rr = testdir .run (* run_args , * cmd_opts , timeout = timeout )
613
+ rr = testdir .run (* cmd_opts , timeout = timeout )
611
614
assert_outcomes (rr , {"passed" : 2 })
612
615
# assert_outcomes(rr, {"passed": 1})
613
616
@@ -655,7 +658,7 @@ async def test_doubleincrement(doubleincrement):
655
658
assert (first, second) == (0, 2)
656
659
""" .format (maybe_async = maybe_async , maybe_await = maybe_await )
657
660
testdir .makepyfile (test_file )
658
- rr = testdir .run (* run_args , * cmd_opts , timeout = timeout )
661
+ rr = testdir .run (* cmd_opts , timeout = timeout )
659
662
assert_outcomes (rr , {"passed" : 2 })
660
663
661
664
@@ -683,7 +686,7 @@ def test_succeed():
683
686
return d
684
687
"""
685
688
testdir .makepyfile (test_file )
686
- rr = testdir .run (* run_args , * cmd_opts , timeout = timeout )
689
+ rr = testdir .run (* cmd_opts , timeout = timeout )
687
690
assert_outcomes (rr , {"passed" : 1 })
688
691
689
692
@@ -700,14 +703,15 @@ def test_succeed():
700
703
pass
701
704
"""
702
705
testdir .makepyfile (test_file )
703
- rr = testdir .run (* run_args , * cmd_opts , timeout = timeout )
706
+ rr = testdir .run (* cmd_opts , timeout = timeout )
704
707
assert "WrongReactorAlreadyInstalledError" in rr .stderr .str ()
705
708
706
709
707
710
def test_blockon_in_hook_with_qt5reactor (testdir , cmd_opts , request ):
708
711
skip_if_reactor_not (request , "qt5reactor" )
709
712
conftest_file = """
710
713
import pytest_twisted as pt
714
+ import pytestqt
711
715
from twisted.internet import defer
712
716
713
717
def pytest_configure(config):
@@ -729,7 +733,7 @@ def test_succeed():
729
733
return d
730
734
"""
731
735
testdir .makepyfile (test_file )
732
- rr = testdir .run (* run_args , * cmd_opts , timeout = timeout )
736
+ rr = testdir .run (* cmd_opts , timeout = timeout )
733
737
assert_outcomes (rr , {"passed" : 1 })
734
738
735
739
@@ -746,11 +750,11 @@ def test_succeed():
746
750
pass
747
751
"""
748
752
testdir .makepyfile (test_file )
749
- rr = testdir .run (* run_args , * cmd_opts , timeout = timeout )
753
+ rr = testdir .run (* cmd_opts , timeout = timeout )
750
754
assert "WrongReactorAlreadyInstalledError" in rr .stderr .str ()
751
755
752
756
753
- def test_pytest_from_reactor_thread (testdir , request ):
757
+ def test_pytest_from_reactor_thread (testdir , cmd_opts , request ):
754
758
skip_if_reactor_not (request , "default" )
755
759
test_file = """
756
760
import pytest
@@ -798,7 +802,7 @@ def main():
798
802
"""
799
803
testdir .makepyfile (runner = runner_file )
800
804
# check test file is ok in standalone mode:
801
- rr = testdir .run (* run_args , timeout = timeout )
805
+ rr = testdir .run (* cmd_opts , timeout = timeout )
802
806
assert_outcomes (rr , {"passed" : 1 , "failed" : 1 })
803
807
# test embedded mode:
804
808
assert testdir .run (sys .executable , "runner.py" , timeout = timeout ).ret == 0
@@ -833,7 +837,7 @@ def test_succeed():
833
837
return d
834
838
"""
835
839
testdir .makepyfile (test_file )
836
- rr = testdir .run (* run_args , * cmd_opts , timeout = timeout )
840
+ rr = testdir .run (* cmd_opts , timeout = timeout )
837
841
assert_outcomes (rr , {"passed" : 1 })
838
842
839
843
@@ -858,7 +862,7 @@ def test_succeed():
858
862
pass
859
863
"""
860
864
testdir .makepyfile (test_file )
861
- rr = testdir .run (* run_args , * cmd_opts , timeout = timeout )
865
+ rr = testdir .run (* cmd_opts , timeout = timeout )
862
866
assert "WrongReactorAlreadyInstalledError" in rr .stderr .str ()
863
867
864
868
@@ -906,5 +910,5 @@ def test_second(foo):
906
910
check_me = 3
907
911
"""
908
912
testdir .makepyfile (test_file )
909
- rr = testdir .run (* run_args , * cmd_opts , timeout = timeout )
913
+ rr = testdir .run (* cmd_opts , timeout = timeout )
910
914
assert_outcomes (rr , {"passed" : 2 })
0 commit comments