Skip to content

Commit

Permalink
Suppress warnings even in the imports
Browse files Browse the repository at this point in the history
Some warnings were raised by `@asyncio.coroutine` decorators (e.g. in `asynctest` since Python 3.9.0), which are executed in class definition, which happens in the importing stage before pytest hooks are executed. By putting the warnings config to the INI file, we shift it to before the imports of any modules.
  • Loading branch information
nolar committed Nov 29, 2020
1 parent 01f0f2d commit 5495eb3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
9 changes: 9 additions & 0 deletions pytest.ini
@@ -0,0 +1,9 @@
[pytest]
# Unexpected warnings should fail the tests. Use `-W ignore` to explicitly disable it.
# Warnings from the testing tools out of our control should not fail the tests.
filterwarnings =
error
ignore:"@coroutine":DeprecationWarning:asynctest
ignore:The loop argument:DeprecationWarning:aiohttp
ignore:The loop argument:DeprecationWarning:aiojobs
ignore:The loop argument:DeprecationWarning:asyncio.queues
9 changes: 0 additions & 9 deletions tests/conftest.py
Expand Up @@ -27,15 +27,6 @@ def pytest_configure(config):
config.addinivalue_line('markers', "e2e: end-to-end tests with real operators.")
config.addinivalue_line('markers', "resource_clustered: (internal parameterizatiom mark).")

# Unexpected warnings should fail the tests. Use `-Wignore` to explicitly disable it.
config.addinivalue_line('filterwarnings', 'error')

# Warnings from the testing tools out of our control should not fail the tests.
config.addinivalue_line('filterwarnings', 'ignore:"@coroutine":DeprecationWarning:asynctest.mock')
config.addinivalue_line('filterwarnings', 'ignore:The loop argument:DeprecationWarning:aiohttp')
config.addinivalue_line('filterwarnings', 'ignore:The loop argument:DeprecationWarning:aiojobs')
config.addinivalue_line('filterwarnings', 'ignore:The loop argument:DeprecationWarning:asyncio.queues') # aiojobs


def pytest_addoption(parser):
parser.addoption("--only-e2e", action="store_true", help="Execute end-to-end tests only.")
Expand Down

0 comments on commit 5495eb3

Please sign in to comment.