Skip to content

Commit 4569682

Browse files
authored
Merge branch 'master' into optional_call_for_decorators
2 parents d085fd2 + 9430d78 commit 4569682

File tree

2 files changed

+85
-1
lines changed

2 files changed

+85
-1
lines changed

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
long_description=long_description,
1111
long_description_content_type="text/x-rst",
1212
author="Ralf Schmitt, Kyle Altendorf, Victor Titor",
13-
author_email="[email protected]",
13+
author_email="[email protected]",
1414
url="https://github.com/pytest-dev/pytest-twisted",
1515
py_modules=["pytest_twisted"],
1616
python_requires='>=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*',

testing/test_basic.py

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -963,3 +963,87 @@ def test_second(foo):
963963
testdir.makepyfile(test_file)
964964
rr = testdir.run(*cmd_opts, timeout=timeout)
965965
assert_outcomes(rr, {"passed": 2})
966+
967+
968+
def test_inlinecallbacks_method_with_fixture_gets_self(testdir, cmd_opts):
969+
test_file = """
970+
import pytest
971+
import pytest_twisted
972+
from twisted.internet import defer
973+
974+
@pytest.fixture
975+
def foo():
976+
return 37
977+
978+
class TestClass:
979+
@pytest_twisted.inlineCallbacks
980+
def test_self_isinstance(self, foo):
981+
d = defer.succeed(None)
982+
yield d
983+
assert isinstance(self, TestClass)
984+
"""
985+
testdir.makepyfile(test_file)
986+
rr = testdir.run(*cmd_opts)
987+
assert_outcomes(rr, {"passed": 1})
988+
989+
990+
def test_inlinecallbacks_method_with_fixture_gets_fixture(testdir, cmd_opts):
991+
test_file = """
992+
import pytest
993+
import pytest_twisted
994+
from twisted.internet import defer
995+
996+
@pytest.fixture
997+
def foo():
998+
return 37
999+
1000+
class TestClass:
1001+
@pytest_twisted.inlineCallbacks
1002+
def test_self_isinstance(self, foo):
1003+
d = defer.succeed(None)
1004+
yield d
1005+
assert foo == 37
1006+
"""
1007+
testdir.makepyfile(test_file)
1008+
rr = testdir.run(*cmd_opts, timeout=timeout)
1009+
assert_outcomes(rr, {"passed": 1})
1010+
1011+
1012+
@skip_if_no_async_await()
1013+
def test_ensuredeferred_method_with_fixture_gets_self(testdir, cmd_opts):
1014+
test_file = """
1015+
import pytest
1016+
import pytest_twisted
1017+
1018+
@pytest.fixture
1019+
def foo():
1020+
return 37
1021+
1022+
class TestClass:
1023+
@pytest_twisted.ensureDeferred
1024+
async def test_self_isinstance(self, foo):
1025+
assert isinstance(self, TestClass)
1026+
"""
1027+
testdir.makepyfile(test_file)
1028+
rr = testdir.run(*cmd_opts, timeout=timeout)
1029+
assert_outcomes(rr, {"passed": 1})
1030+
1031+
1032+
@skip_if_no_async_await()
1033+
def test_ensuredeferred_method_with_fixture_gets_fixture(testdir, cmd_opts):
1034+
test_file = """
1035+
import pytest
1036+
import pytest_twisted
1037+
1038+
@pytest.fixture
1039+
def foo():
1040+
return 37
1041+
1042+
class TestClass:
1043+
@pytest_twisted.ensureDeferred
1044+
async def test_self_isinstance(self, foo):
1045+
assert foo == 37
1046+
"""
1047+
testdir.makepyfile(test_file)
1048+
rr = testdir.run(*cmd_opts, timeout=timeout)
1049+
assert_outcomes(rr, {"passed": 1})

0 commit comments

Comments
 (0)