Skip to content

Commit 9107203

Browse files
committed
more tidying
1 parent fa4ed97 commit 9107203

File tree

2 files changed

+32
-28
lines changed

2 files changed

+32
-28
lines changed

pytest_twisted.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
import greenlet
88
import pytest
99

10-
from twisted.internet import error, defer
10+
from twisted.internet import defer
11+
# from twisted.internet import error
1112
from twisted.internet.threads import blockingCallFromThread
1213
from twisted.python import failure
1314

testing/test_basic.py

Lines changed: 30 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,9 @@ def test_inline_callbacks_in_pytest():
9696
assert hasattr(pytest, 'inlineCallbacks')
9797

9898

99+
run_args = [sys.executable, "-m", "pytest", "-v"]
100+
101+
99102
@pytest.mark.parametrize(
100103
'decorator, should_warn',
101104
(
@@ -119,7 +122,7 @@ def f():
119122
yield 42
120123
""".format(import_path=import_path, decorator=decorator)
121124
testdir.makepyfile(test_file)
122-
rr = testdir.run(sys.executable, "-m", "pytest", "-v", *cmd_opts, timeout=timeout)
125+
rr = testdir.run(*run_args, *cmd_opts, timeout=timeout)
123126

124127
expected_outcomes = {"passed": 1}
125128
if should_warn:
@@ -163,7 +166,7 @@ def test_succeed(foo):
163166
pass
164167
""".format(import_path=import_path, function=function)
165168
testdir.makepyfile(test_file)
166-
rr = testdir.run(sys.executable, "-m", "pytest", "-v", *cmd_opts, timeout=timeout)
169+
rr = testdir.run(*run_args, *cmd_opts, timeout=timeout)
167170

168171
expected_outcomes = {"passed": 1}
169172
if should_warn:
@@ -188,7 +191,7 @@ def doit():
188191
return d
189192
"""
190193
testdir.makepyfile(test_file)
191-
rr = testdir.run(sys.executable, "-m", "pytest", *cmd_opts, timeout=timeout)
194+
rr = testdir.run(*run_args, *cmd_opts, timeout=timeout)
192195
assert_outcomes(rr, {"failed": 1})
193196

194197

@@ -202,7 +205,7 @@ def test_succeed():
202205
return d
203206
"""
204207
testdir.makepyfile(test_file)
205-
rr = testdir.run(sys.executable, "-m", "pytest", *cmd_opts, timeout=timeout)
208+
rr = testdir.run(*run_args, *cmd_opts, timeout=timeout)
206209
assert_outcomes(rr, {"passed": 1})
207210

208211

@@ -214,7 +217,7 @@ def test_succeed():
214217
return 42
215218
"""
216219
testdir.makepyfile(test_file)
217-
rr = testdir.run(sys.executable, "-m", "pytest", *cmd_opts, timeout=timeout)
220+
rr = testdir.run(*run_args, *cmd_opts, timeout=timeout)
218221
assert_outcomes(rr, {"passed": 1})
219222

220223

@@ -224,7 +227,7 @@ def test_more_fail():
224227
raise RuntimeError("foo")
225228
"""
226229
testdir.makepyfile(test_file)
227-
rr = testdir.run(sys.executable, "-m", "pytest", *cmd_opts, timeout=timeout)
230+
rr = testdir.run(*run_args, *cmd_opts, timeout=timeout)
228231
assert_outcomes(rr, {"failed": 1})
229232

230233

@@ -245,7 +248,7 @@ def test_succeed(foo):
245248
raise RuntimeError("baz")
246249
"""
247250
testdir.makepyfile(test_file)
248-
rr = testdir.run(sys.executable, "-m", "pytest", "-v", *cmd_opts, timeout=timeout)
251+
rr = testdir.run(*run_args, *cmd_opts, timeout=timeout)
249252
assert_outcomes(rr, {"passed": 2, "failed": 1})
250253

251254

@@ -267,7 +270,7 @@ async def test_succeed(foo):
267270
raise RuntimeError("baz")
268271
"""
269272
testdir.makepyfile(test_file)
270-
rr = testdir.run(sys.executable, "-m", "pytest", "-v", *cmd_opts, timeout=timeout)
273+
rr = testdir.run(*run_args, *cmd_opts, timeout=timeout)
271274
assert_outcomes(rr, {"passed": 2, "failed": 1})
272275

273276

@@ -287,7 +290,7 @@ def test_MAIN():
287290
assert MAIN is greenlet.getcurrent()
288291
"""
289292
testdir.makepyfile(test_file)
290-
rr = testdir.run(sys.executable, "-m", "pytest", "-v", *cmd_opts, timeout=timeout)
293+
rr = testdir.run(*run_args, *cmd_opts, timeout=timeout)
291294
assert_outcomes(rr, {"passed": 1})
292295

293296

@@ -312,7 +315,7 @@ def test_succeed(foo):
312315
raise RuntimeError("baz")
313316
"""
314317
testdir.makepyfile(test_file)
315-
rr = testdir.run(sys.executable, "-m", "pytest", "-v", *cmd_opts, timeout=timeout)
318+
rr = testdir.run(*run_args, *cmd_opts, timeout=timeout)
316319
assert_outcomes(rr, {"passed": 2, "failed": 1})
317320

318321

@@ -338,7 +341,7 @@ async def test_succeed(foo):
338341
raise RuntimeError("baz")
339342
"""
340343
testdir.makepyfile(test_file)
341-
rr = testdir.run(sys.executable, "-m", "pytest", "-v", *cmd_opts, timeout=timeout)
344+
rr = testdir.run(*run_args, *cmd_opts, timeout=timeout)
342345
assert_outcomes(rr, {"passed": 2, "failed": 1})
343346

344347

@@ -374,7 +377,7 @@ def test_succeed_blue(foo):
374377
raise RuntimeError("baz")
375378
"""
376379
testdir.makepyfile(test_file)
377-
rr = testdir.run(sys.executable, "-m", "pytest", "-v", *cmd_opts, timeout=timeout)
380+
rr = testdir.run(*run_args, *cmd_opts, timeout=timeout)
378381
assert_outcomes(rr, {"passed": 2, "failed": 1})
379382

380383

@@ -411,7 +414,7 @@ def test_succeed(this, that):
411414
testdir.makepyfile(test_file)
412415
# TODO: add a timeout, failure just hangs indefinitely for now
413416
# https://github.com/pytest-dev/pytest/issues/4073
414-
rr = testdir.run(sys.executable, "-m", "pytest", "-v", *cmd_opts, timeout=timeout)
417+
rr = testdir.run(*run_args, *cmd_opts, timeout=timeout)
415418
assert_outcomes(rr, {"passed": 1})
416419

417420

@@ -450,7 +453,7 @@ def test_succeed(foo):
450453
raise RuntimeError("baz")
451454
"""
452455
testdir.makepyfile(test_file)
453-
rr = testdir.run(sys.executable, "-m", "pytest", "-v", *cmd_opts, timeout=timeout)
456+
rr = testdir.run(*run_args, *cmd_opts, timeout=timeout)
454457
# TODO: this is getting super imprecise...
455458
assert_outcomes(rr, {"passed": 4, "failed": 1, "errors": 2})
456459

@@ -499,7 +502,7 @@ def test_second(foo):
499502
check_me = 2
500503
"""
501504
testdir.makepyfile(test_file)
502-
rr = testdir.run(sys.executable, "-m", "pytest", "-v", *cmd_opts, timeout=timeout)
505+
rr = testdir.run(*run_args, *cmd_opts, timeout=timeout)
503506
assert_outcomes(rr, {"passed": 2})
504507

505508

@@ -528,7 +531,7 @@ async def test_doublefour(doublefour):
528531
assert doublefour == 8
529532
"""
530533
testdir.makepyfile(test_file)
531-
rr = testdir.run(sys.executable, "-m", "pytest", "-v", *cmd_opts, timeout=timeout)
534+
rr = testdir.run(*run_args, *cmd_opts, timeout=timeout)
532535
assert_outcomes(rr, {"passed": 2})
533536

534537

@@ -557,7 +560,7 @@ async def test_doublefour(doublefour):
557560
assert doublefour == 8
558561
"""
559562
testdir.makepyfile(test_file)
560-
rr = testdir.run(sys.executable, "-m", "pytest", "-v", *cmd_opts, timeout=timeout)
563+
rr = testdir.run(*run_args, *cmd_opts, timeout=timeout)
561564
assert_outcomes(rr, {"passed": 2})
562565

563566

@@ -604,7 +607,7 @@ async def test_doubleincrement(doubleincrement):
604607
assert (first, second) == (0, 2)
605608
""".format(maybe_async=maybe_async, maybe_await=maybe_await)
606609
testdir.makepyfile(test_file)
607-
rr = testdir.run(sys.executable, "-m", "pytest", "-v", *cmd_opts, timeout=timeout)
610+
rr = testdir.run(*run_args, *cmd_opts, timeout=timeout)
608611
assert_outcomes(rr, {"passed": 2})
609612
# assert_outcomes(rr, {"passed": 1})
610613

@@ -652,7 +655,7 @@ async def test_doubleincrement(doubleincrement):
652655
assert (first, second) == (0, 2)
653656
""".format(maybe_async=maybe_async, maybe_await=maybe_await)
654657
testdir.makepyfile(test_file)
655-
rr = testdir.run(sys.executable, "-m", "pytest", "-v", *cmd_opts, timeout=timeout)
658+
rr = testdir.run(*run_args, *cmd_opts, timeout=timeout)
656659
assert_outcomes(rr, {"passed": 2})
657660

658661

@@ -680,7 +683,7 @@ def test_succeed():
680683
return d
681684
"""
682685
testdir.makepyfile(test_file)
683-
rr = testdir.run(sys.executable, "-m", "pytest", "-v", *cmd_opts, timeout=timeout)
686+
rr = testdir.run(*run_args, *cmd_opts, timeout=timeout)
684687
assert_outcomes(rr, {"passed": 1})
685688

686689

@@ -697,7 +700,7 @@ def test_succeed():
697700
pass
698701
"""
699702
testdir.makepyfile(test_file)
700-
rr = testdir.run(sys.executable, "-m", "pytest", "-v", *cmd_opts, timeout=timeout)
703+
rr = testdir.run(*run_args, *cmd_opts, timeout=timeout)
701704
assert "WrongReactorAlreadyInstalledError" in rr.stderr.str()
702705

703706

@@ -726,7 +729,7 @@ def test_succeed():
726729
return d
727730
"""
728731
testdir.makepyfile(test_file)
729-
rr = testdir.run(sys.executable, "-m", "pytest", "-v", *cmd_opts, timeout=timeout)
732+
rr = testdir.run(*run_args, *cmd_opts, timeout=timeout)
730733
assert_outcomes(rr, {"passed": 1})
731734

732735

@@ -743,7 +746,7 @@ def test_succeed():
743746
pass
744747
"""
745748
testdir.makepyfile(test_file)
746-
rr = testdir.run(sys.executable, "-m", "pytest", "-v", *cmd_opts, timeout=timeout)
749+
rr = testdir.run(*run_args, *cmd_opts, timeout=timeout)
747750
assert "WrongReactorAlreadyInstalledError" in rr.stderr.str()
748751

749752

@@ -795,7 +798,7 @@ def main():
795798
"""
796799
testdir.makepyfile(runner=runner_file)
797800
# check test file is ok in standalone mode:
798-
rr = testdir.run(sys.executable, "-m", "pytest", "-v", timeout=timeout)
801+
rr = testdir.run(*run_args, timeout=timeout)
799802
assert_outcomes(rr, {"passed": 1, "failed": 1})
800803
# test embedded mode:
801804
assert testdir.run(sys.executable, "runner.py", timeout=timeout).ret == 0
@@ -830,7 +833,7 @@ def test_succeed():
830833
return d
831834
"""
832835
testdir.makepyfile(test_file)
833-
rr = testdir.run(sys.executable, "-m", "pytest", "-v", *cmd_opts, timeout=timeout)
836+
rr = testdir.run(*run_args, *cmd_opts, timeout=timeout)
834837
assert_outcomes(rr, {"passed": 1})
835838

836839

@@ -855,7 +858,7 @@ def test_succeed():
855858
pass
856859
"""
857860
testdir.makepyfile(test_file)
858-
rr = testdir.run(sys.executable, "-m", "pytest", "-v", *cmd_opts, timeout=timeout)
861+
rr = testdir.run(*run_args, *cmd_opts, timeout=timeout)
859862
assert "WrongReactorAlreadyInstalledError" in rr.stderr.str()
860863

861864

@@ -903,5 +906,5 @@ def test_second(foo):
903906
check_me = 3
904907
"""
905908
testdir.makepyfile(test_file)
906-
rr = testdir.run(sys.executable, "-m", "pytest", "-v", *cmd_opts, timeout=timeout)
909+
rr = testdir.run(*run_args, *cmd_opts, timeout=timeout)
907910
assert_outcomes(rr, {"passed": 2})

0 commit comments

Comments
 (0)