Skip to content

Commit ae3d2b2

Browse files
committed
Merge branch 'master' into 35-altendky-tidy_async_await_fixtures
2 parents 3ac4209 + a9ed941 commit ae3d2b2

File tree

5 files changed

+30
-24
lines changed

5 files changed

+30
-24
lines changed

README.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,9 @@ That's all.
115115
:alt: Travis build status
116116
:target: https://travis-ci.org/pytest-dev/pytest-twisted
117117

118-
.. |AppVeyor| image:: https://ci.appveyor.com/api/projects/status/us5l0l9p7hyp2k6x/branch/master?svg=true
118+
.. |AppVeyor| image:: https://ci.appveyor.com/api/projects/status/eb1vp9hysp463c66/branch/master?svg=true
119119
:alt: AppVeyor build status
120-
:target: https://ci.appveyor.com/project/vtitor/pytest-twisted
120+
:target: https://ci.appveyor.com/project/pytestbot/pytest-twisted
121121

122122
.. |Black| image:: https://img.shields.io/badge/code%20style-black-000000.svg
123123
:alt: Black code style

pytest.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[pytest]
2+
filterwarnings = error

pytest_twisted.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,6 @@ class _instances:
3636
reactor = None
3737

3838

39-
def pytest_namespace():
40-
return {"inlineCallbacks": inlineCallbacks, "blockon": blockon}
41-
42-
4339
def blockon(d):
4440
if _config.external_reactor:
4541
return block_from_thread(d)
@@ -260,4 +256,6 @@ def pytest_addoption(parser):
260256

261257

262258
def pytest_configure(config):
259+
pytest.inlineCallbacks = inlineCallbacks
260+
pytest.blockon = blockon
263261
reactor_installers[config.getoption("reactor")]()

testing/test_basic.py

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,10 @@ def format_run_result_output_for_assert(run_result):
3131
)
3232

3333

34-
def skip_if_reactor_not(expected_reactor):
35-
actual_reactor = pytest.config.getoption("reactor", "default")
36-
return pytest.mark.skipif(
37-
actual_reactor != expected_reactor,
38-
reason="reactor is {} not {}".format(actual_reactor, expected_reactor),
39-
)
34+
def skip_if_reactor_not(request, expected_reactor):
35+
actual_reactor = request.config.getoption("reactor", "default")
36+
if actual_reactor != expected_reactor:
37+
pytest.skip("reactor is {} not {}".format(actual_reactor, expected_reactor))
4038

4139

4240
def skip_if_no_async_await():
@@ -59,6 +57,14 @@ def cmd_opts(request):
5957
return ("--reactor={}".format(reactor),)
6058

6159

60+
def test_inline_callbacks_in_pytest():
61+
assert hasattr(pytest, 'inlineCallbacks')
62+
63+
64+
def test_blockon_in_pytest():
65+
assert hasattr(pytest, 'blockon')
66+
67+
6268
def test_fail_later(testdir, cmd_opts):
6369
test_file = """
6470
from twisted.internet import reactor, defer
@@ -284,8 +290,8 @@ def test_succeed(foo):
284290
assert_outcomes(rr, {"passed": 2, "failed": 3})
285291

286292

287-
@skip_if_reactor_not("default")
288-
def test_blockon_in_hook(testdir, cmd_opts):
293+
def test_blockon_in_hook(testdir, cmd_opts, request):
294+
skip_if_reactor_not(request, "default")
289295
conftest_file = """
290296
import pytest_twisted as pt
291297
from twisted.internet import reactor, defer
@@ -312,8 +318,8 @@ def test_succeed():
312318
assert_outcomes(rr, {"passed": 1})
313319

314320

315-
@skip_if_reactor_not("default")
316-
def test_wrong_reactor(testdir, cmd_opts):
321+
def test_wrong_reactor(testdir, cmd_opts, request):
322+
skip_if_reactor_not(request, "default")
317323
conftest_file = """
318324
def pytest_addhooks():
319325
import twisted.internet.reactor
@@ -329,8 +335,8 @@ def test_succeed():
329335
assert "WrongReactorAlreadyInstalledError" in rr.stderr.str()
330336

331337

332-
@skip_if_reactor_not("qt5reactor")
333-
def test_blockon_in_hook_with_qt5reactor(testdir, cmd_opts):
338+
def test_blockon_in_hook_with_qt5reactor(testdir, cmd_opts, request):
339+
skip_if_reactor_not(request, "qt5reactor")
334340
conftest_file = """
335341
import pytest_twisted as pt
336342
import pytestqt
@@ -359,8 +365,8 @@ def test_succeed():
359365
assert_outcomes(rr, {"passed": 1})
360366

361367

362-
@skip_if_reactor_not("qt5reactor")
363-
def test_wrong_reactor_with_qt5reactor(testdir, cmd_opts):
368+
def test_wrong_reactor_with_qt5reactor(testdir, cmd_opts, request):
369+
skip_if_reactor_not(request, "qt5reactor")
364370
conftest_file = """
365371
def pytest_addhooks():
366372
import twisted.internet.default
@@ -376,8 +382,8 @@ def test_succeed():
376382
assert "WrongReactorAlreadyInstalledError" in rr.stderr.str()
377383

378384

379-
@skip_if_reactor_not("default")
380-
def test_pytest_from_reactor_thread(testdir):
385+
def test_pytest_from_reactor_thread(testdir, request):
386+
skip_if_reactor_not(request, "default")
381387
test_file = """
382388
import pytest
383389
import pytest_twisted

tox.ini

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ deps=
1616
qt5reactor: pyqt5
1717
win: pywin32
1818
commands=
19-
defaultreactor: py.test --reactor=default
20-
qt5reactor: py.test --reactor=qt5reactor
19+
defaultreactor: pytest --reactor=default
20+
qt5reactor: pytest --reactor=qt5reactor
2121
sitepackages=False
2222

2323
[testenv:linting]

0 commit comments

Comments
 (0)