diff options
author | Ran Benita <ran@unusedvar.com> | 2020-07-01 20:08:56 +0300 |
---|---|---|
committer | Ran Benita <ran@unusedvar.com> | 2020-07-01 20:29:04 +0300 |
commit | c8cfff6de5d57c59d7a394f45678386f4d0b5015 (patch) | |
tree | c645f23388133ca2f8017c6d74c40c130cd4eff0 /testing/acceptance_test.py | |
parent | e6e300e729dd33956e5448d8be9a0b1540b4e53a (diff) | |
download | pytest-c8cfff6de5d57c59d7a394f45678386f4d0b5015.tar.gz |
testing: fix flaky tests due to "coroutine never awaited" warnings
They sometime leak into other test's warnings and cause them to fail.
Diffstat (limited to 'testing/acceptance_test.py')
-rw-r--r-- | testing/acceptance_test.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/testing/acceptance_test.py b/testing/acceptance_test.py index 66c2bf0bf..e558c7f67 100644 --- a/testing/acceptance_test.py +++ b/testing/acceptance_test.py @@ -1160,6 +1160,9 @@ def test_usage_error_code(testdir): @pytest.mark.filterwarnings("default") def test_warn_on_async_function(testdir): + # In the below we .close() the coroutine only to avoid + # "RuntimeWarning: coroutine 'test_2' was never awaited" + # which messes with other tests. testdir.makepyfile( test_async=""" async def test_1(): @@ -1167,7 +1170,9 @@ def test_warn_on_async_function(testdir): async def test_2(): pass def test_3(): - return test_2() + coro = test_2() + coro.close() + return coro """ ) result = testdir.runpytest() |