Skip to content

Commit a0feeda

Browse files
committed
maybe
1 parent 9107203 commit a0feeda

File tree

2 files changed

+37
-34
lines changed

2 files changed

+37
-34
lines changed

testing/test_basic.py

Lines changed: 36 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -89,16 +89,19 @@ def skip_if_no_async_generators():
8989
@pytest.fixture
9090
def cmd_opts(request):
9191
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+
)
9399

94100

95101
def test_inline_callbacks_in_pytest():
96102
assert hasattr(pytest, 'inlineCallbacks')
97103

98104

99-
run_args = [sys.executable, "-m", "pytest", "-v"]
100-
101-
102105
@pytest.mark.parametrize(
103106
'decorator, should_warn',
104107
(
@@ -122,7 +125,7 @@ def f():
122125
yield 42
123126
""".format(import_path=import_path, decorator=decorator)
124127
testdir.makepyfile(test_file)
125-
rr = testdir.run(*run_args, *cmd_opts, timeout=timeout)
128+
rr = testdir.run(*cmd_opts, timeout=timeout)
126129

127130
expected_outcomes = {"passed": 1}
128131
if should_warn:
@@ -166,7 +169,7 @@ def test_succeed(foo):
166169
pass
167170
""".format(import_path=import_path, function=function)
168171
testdir.makepyfile(test_file)
169-
rr = testdir.run(*run_args, *cmd_opts, timeout=timeout)
172+
rr = testdir.run(*cmd_opts, timeout=timeout)
170173

171174
expected_outcomes = {"passed": 1}
172175
if should_warn:
@@ -191,7 +194,7 @@ def doit():
191194
return d
192195
"""
193196
testdir.makepyfile(test_file)
194-
rr = testdir.run(*run_args, *cmd_opts, timeout=timeout)
197+
rr = testdir.run(*cmd_opts, timeout=timeout)
195198
assert_outcomes(rr, {"failed": 1})
196199

197200

@@ -205,7 +208,7 @@ def test_succeed():
205208
return d
206209
"""
207210
testdir.makepyfile(test_file)
208-
rr = testdir.run(*run_args, *cmd_opts, timeout=timeout)
211+
rr = testdir.run(*cmd_opts, timeout=timeout)
209212
assert_outcomes(rr, {"passed": 1})
210213

211214

@@ -217,7 +220,7 @@ def test_succeed():
217220
return 42
218221
"""
219222
testdir.makepyfile(test_file)
220-
rr = testdir.run(*run_args, *cmd_opts, timeout=timeout)
223+
rr = testdir.run(*cmd_opts, timeout=timeout)
221224
assert_outcomes(rr, {"passed": 1})
222225

223226

@@ -227,7 +230,7 @@ def test_more_fail():
227230
raise RuntimeError("foo")
228231
"""
229232
testdir.makepyfile(test_file)
230-
rr = testdir.run(*run_args, *cmd_opts, timeout=timeout)
233+
rr = testdir.run(*cmd_opts, timeout=timeout)
231234
assert_outcomes(rr, {"failed": 1})
232235

233236

@@ -248,7 +251,7 @@ def test_succeed(foo):
248251
raise RuntimeError("baz")
249252
"""
250253
testdir.makepyfile(test_file)
251-
rr = testdir.run(*run_args, *cmd_opts, timeout=timeout)
254+
rr = testdir.run(*cmd_opts, timeout=timeout)
252255
assert_outcomes(rr, {"passed": 2, "failed": 1})
253256

254257

@@ -270,7 +273,7 @@ async def test_succeed(foo):
270273
raise RuntimeError("baz")
271274
"""
272275
testdir.makepyfile(test_file)
273-
rr = testdir.run(*run_args, *cmd_opts, timeout=timeout)
276+
rr = testdir.run(*cmd_opts, timeout=timeout)
274277
assert_outcomes(rr, {"passed": 2, "failed": 1})
275278

276279

@@ -290,7 +293,7 @@ def test_MAIN():
290293
assert MAIN is greenlet.getcurrent()
291294
"""
292295
testdir.makepyfile(test_file)
293-
rr = testdir.run(*run_args, *cmd_opts, timeout=timeout)
296+
rr = testdir.run(*cmd_opts, timeout=timeout)
294297
assert_outcomes(rr, {"passed": 1})
295298

296299

@@ -315,7 +318,7 @@ def test_succeed(foo):
315318
raise RuntimeError("baz")
316319
"""
317320
testdir.makepyfile(test_file)
318-
rr = testdir.run(*run_args, *cmd_opts, timeout=timeout)
321+
rr = testdir.run(*cmd_opts, timeout=timeout)
319322
assert_outcomes(rr, {"passed": 2, "failed": 1})
320323

321324

@@ -341,7 +344,7 @@ async def test_succeed(foo):
341344
raise RuntimeError("baz")
342345
"""
343346
testdir.makepyfile(test_file)
344-
rr = testdir.run(*run_args, *cmd_opts, timeout=timeout)
347+
rr = testdir.run(*cmd_opts, timeout=timeout)
345348
assert_outcomes(rr, {"passed": 2, "failed": 1})
346349

347350

@@ -377,7 +380,7 @@ def test_succeed_blue(foo):
377380
raise RuntimeError("baz")
378381
"""
379382
testdir.makepyfile(test_file)
380-
rr = testdir.run(*run_args, *cmd_opts, timeout=timeout)
383+
rr = testdir.run(*cmd_opts, timeout=timeout)
381384
assert_outcomes(rr, {"passed": 2, "failed": 1})
382385

383386

@@ -414,7 +417,7 @@ def test_succeed(this, that):
414417
testdir.makepyfile(test_file)
415418
# TODO: add a timeout, failure just hangs indefinitely for now
416419
# 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)
418421
assert_outcomes(rr, {"passed": 1})
419422

420423

@@ -453,7 +456,7 @@ def test_succeed(foo):
453456
raise RuntimeError("baz")
454457
"""
455458
testdir.makepyfile(test_file)
456-
rr = testdir.run(*run_args, *cmd_opts, timeout=timeout)
459+
rr = testdir.run(*cmd_opts, timeout=timeout)
457460
# TODO: this is getting super imprecise...
458461
assert_outcomes(rr, {"passed": 4, "failed": 1, "errors": 2})
459462

@@ -502,7 +505,7 @@ def test_second(foo):
502505
check_me = 2
503506
"""
504507
testdir.makepyfile(test_file)
505-
rr = testdir.run(*run_args, *cmd_opts, timeout=timeout)
508+
rr = testdir.run(*cmd_opts, timeout=timeout)
506509
assert_outcomes(rr, {"passed": 2})
507510

508511

@@ -531,7 +534,7 @@ async def test_doublefour(doublefour):
531534
assert doublefour == 8
532535
"""
533536
testdir.makepyfile(test_file)
534-
rr = testdir.run(*run_args, *cmd_opts, timeout=timeout)
537+
rr = testdir.run(*cmd_opts, timeout=timeout)
535538
assert_outcomes(rr, {"passed": 2})
536539

537540

@@ -560,7 +563,7 @@ async def test_doublefour(doublefour):
560563
assert doublefour == 8
561564
"""
562565
testdir.makepyfile(test_file)
563-
rr = testdir.run(*run_args, *cmd_opts, timeout=timeout)
566+
rr = testdir.run(*cmd_opts, timeout=timeout)
564567
assert_outcomes(rr, {"passed": 2})
565568

566569

@@ -607,7 +610,7 @@ async def test_doubleincrement(doubleincrement):
607610
assert (first, second) == (0, 2)
608611
""".format(maybe_async=maybe_async, maybe_await=maybe_await)
609612
testdir.makepyfile(test_file)
610-
rr = testdir.run(*run_args, *cmd_opts, timeout=timeout)
613+
rr = testdir.run(*cmd_opts, timeout=timeout)
611614
assert_outcomes(rr, {"passed": 2})
612615
# assert_outcomes(rr, {"passed": 1})
613616

@@ -655,7 +658,7 @@ async def test_doubleincrement(doubleincrement):
655658
assert (first, second) == (0, 2)
656659
""".format(maybe_async=maybe_async, maybe_await=maybe_await)
657660
testdir.makepyfile(test_file)
658-
rr = testdir.run(*run_args, *cmd_opts, timeout=timeout)
661+
rr = testdir.run(*cmd_opts, timeout=timeout)
659662
assert_outcomes(rr, {"passed": 2})
660663

661664

@@ -683,7 +686,7 @@ def test_succeed():
683686
return d
684687
"""
685688
testdir.makepyfile(test_file)
686-
rr = testdir.run(*run_args, *cmd_opts, timeout=timeout)
689+
rr = testdir.run(*cmd_opts, timeout=timeout)
687690
assert_outcomes(rr, {"passed": 1})
688691

689692

@@ -700,14 +703,15 @@ def test_succeed():
700703
pass
701704
"""
702705
testdir.makepyfile(test_file)
703-
rr = testdir.run(*run_args, *cmd_opts, timeout=timeout)
706+
rr = testdir.run(*cmd_opts, timeout=timeout)
704707
assert "WrongReactorAlreadyInstalledError" in rr.stderr.str()
705708

706709

707710
def test_blockon_in_hook_with_qt5reactor(testdir, cmd_opts, request):
708711
skip_if_reactor_not(request, "qt5reactor")
709712
conftest_file = """
710713
import pytest_twisted as pt
714+
import pytestqt
711715
from twisted.internet import defer
712716
713717
def pytest_configure(config):
@@ -729,7 +733,7 @@ def test_succeed():
729733
return d
730734
"""
731735
testdir.makepyfile(test_file)
732-
rr = testdir.run(*run_args, *cmd_opts, timeout=timeout)
736+
rr = testdir.run(*cmd_opts, timeout=timeout)
733737
assert_outcomes(rr, {"passed": 1})
734738

735739

@@ -746,11 +750,11 @@ def test_succeed():
746750
pass
747751
"""
748752
testdir.makepyfile(test_file)
749-
rr = testdir.run(*run_args, *cmd_opts, timeout=timeout)
753+
rr = testdir.run(*cmd_opts, timeout=timeout)
750754
assert "WrongReactorAlreadyInstalledError" in rr.stderr.str()
751755

752756

753-
def test_pytest_from_reactor_thread(testdir, request):
757+
def test_pytest_from_reactor_thread(testdir, cmd_opts, request):
754758
skip_if_reactor_not(request, "default")
755759
test_file = """
756760
import pytest
@@ -798,7 +802,7 @@ def main():
798802
"""
799803
testdir.makepyfile(runner=runner_file)
800804
# check test file is ok in standalone mode:
801-
rr = testdir.run(*run_args, timeout=timeout)
805+
rr = testdir.run(*cmd_opts, timeout=timeout)
802806
assert_outcomes(rr, {"passed": 1, "failed": 1})
803807
# test embedded mode:
804808
assert testdir.run(sys.executable, "runner.py", timeout=timeout).ret == 0
@@ -833,7 +837,7 @@ def test_succeed():
833837
return d
834838
"""
835839
testdir.makepyfile(test_file)
836-
rr = testdir.run(*run_args, *cmd_opts, timeout=timeout)
840+
rr = testdir.run(*cmd_opts, timeout=timeout)
837841
assert_outcomes(rr, {"passed": 1})
838842

839843

@@ -858,7 +862,7 @@ def test_succeed():
858862
pass
859863
"""
860864
testdir.makepyfile(test_file)
861-
rr = testdir.run(*run_args, *cmd_opts, timeout=timeout)
865+
rr = testdir.run(*cmd_opts, timeout=timeout)
862866
assert "WrongReactorAlreadyInstalledError" in rr.stderr.str()
863867

864868

@@ -906,5 +910,5 @@ def test_second(foo):
906910
check_me = 3
907911
"""
908912
testdir.makepyfile(test_file)
909-
rr = testdir.run(*run_args, *cmd_opts, timeout=timeout)
913+
rr = testdir.run(*cmd_opts, timeout=timeout)
910914
assert_outcomes(rr, {"passed": 2})

tox.ini

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,9 @@ deps=
1818
setenv=
1919
defaultreactor: REACTOR = default
2020
qt5reactor: REACTOR = qt5reactor
21-
qt5reactor: OPTIONS = -s --no-qt-log
2221
asyncioreactor: REACTOR = asyncio
2322
commands=
24-
pytest --reactor={env:REACTOR} {env:OPTIONS:}
23+
pytest --reactor={env:REACTOR}
2524
sitepackages=False
2625
download=true
2726

0 commit comments

Comments
 (0)