-
Notifications
You must be signed in to change notification settings - Fork 213
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
106 additions
and
2 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import textwrap | ||
|
||
|
||
# TODO: Split this test in one that checks that we work correctly | ||
# with the pytest-asyncio plugin, and another that checks that we correctly | ||
# run async steps. | ||
def test_async_steps(pytester): | ||
"""Test parent given is collected. | ||
Both fixtures come from the parent conftest. | ||
""" | ||
pytester.makefile( | ||
".feature", | ||
async_feature=textwrap.dedent( | ||
"""\ | ||
Feature: A feature | ||
Scenario: A scenario | ||
Given There is an async object | ||
When I do an async action | ||
Then the async object value should be "async_object" | ||
And [async] the async object value should be "async_object" | ||
And the another async object value should be "another_async_object" | ||
""" | ||
), | ||
) | ||
|
||
pytester.makepyfile( | ||
textwrap.dedent( | ||
"""\ | ||
from pytest_bdd import given, parsers, scenarios, then, when | ||
import asyncio | ||
import pytest | ||
scenarios("async_feature.feature") | ||
@pytest.fixture | ||
async def another_async_object(): | ||
await asyncio.sleep(0.01) | ||
return "another_async_object" | ||
@given("There is an async object", target_fixture="async_object") | ||
async def given_async_obj(): | ||
await asyncio.sleep(0.01) | ||
return "async_object" | ||
@when("I do an async action") | ||
async def when_i_do_async_action(): | ||
await asyncio.sleep(0.01) | ||
@then(parsers.parse('the async object value should be "{value}"')) | ||
async def the_sync_object_value_should_be(async_object, value): | ||
assert async_object == value | ||
@then(parsers.parse('[async] the async object value should be "{value}"')) | ||
async def async_the_async_object_value_should_be(async_object, value): | ||
await asyncio.sleep(0.01) | ||
assert async_object == value | ||
@then(parsers.parse('the another async object value should be "{value}"')) | ||
def the_another_async_object_value_should_be(another_async_object, value): | ||
assert another_async_object == value | ||
""" | ||
) | ||
) | ||
result = pytester.runpytest("--asyncio-mode=auto") | ||
result.assert_outcomes(passed=1) |