Skip to content

Commit bf0338f

Browse files
committed
Add simpler tests that still reproduce the issue
1 parent 61acd1a commit bf0338f

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed

testing/test_basic.py

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,64 @@ def test_second(foo):
494494
assert_outcomes(rr, {"passed": 2})
495495

496496

497+
@skip_if_no_async_await()
498+
def test_async_simple_fixture_in_fixture(testdir, cmd_opts):
499+
test_file = """
500+
import itertools
501+
from twisted.internet import reactor, defer
502+
import pytest
503+
import pytest_twisted
504+
505+
@pytest_twisted.async_fixture(name='four')
506+
async def fixture_four():
507+
return 4
508+
509+
@pytest_twisted.async_fixture(name='doublefour')
510+
async def fixture_doublefour(four):
511+
return 2 * four
512+
513+
@pytest_twisted.ensureDeferred
514+
async def test_four(four):
515+
assert four == 4
516+
517+
@pytest_twisted.ensureDeferred
518+
async def test_doublefour(doublefour):
519+
assert doublefour == 8
520+
"""
521+
testdir.makepyfile(test_file)
522+
rr = testdir.run(sys.executable, "-m", "pytest", "-v", *cmd_opts)
523+
assert_outcomes(rr, {"passed": 2})
524+
525+
526+
@skip_if_no_async_generators()
527+
def test_async_yield_simple_fixture_in_fixture(testdir, cmd_opts):
528+
test_file = """
529+
import itertools
530+
from twisted.internet import reactor, defer
531+
import pytest
532+
import pytest_twisted
533+
534+
@pytest_twisted.async_yield_fixture(name='four')
535+
async def fixture_four():
536+
yield 4
537+
538+
@pytest_twisted.async_yield_fixture(name='doublefour')
539+
async def fixture_doublefour(four):
540+
yield 2 * four
541+
542+
@pytest_twisted.ensureDeferred
543+
async def test_four(four):
544+
assert four == 4
545+
546+
@pytest_twisted.ensureDeferred
547+
async def test_doublefour(doublefour):
548+
assert doublefour == 8
549+
"""
550+
testdir.makepyfile(test_file)
551+
rr = testdir.run(sys.executable, "-m", "pytest", "-v", *cmd_opts)
552+
assert_outcomes(rr, {"passed": 2})
553+
554+
497555
@skip_if_no_async_await()
498556
@pytest.mark.parametrize('innerasync', [
499557
pytest.param(truth, id='innerasync={}'.format(truth))

0 commit comments

Comments
 (0)