If there is any warning when running a test, it must fail.
This will help preventing the use of deprecated/obsolete functions and to ensure a good use of the language (not comparing bytes against strings for instance, or prevent file leaks).
This can be easily done with that pytest fixture:
@pytest.fixture(autouse=True) def no_warnings(recwarn): """Fail on warning.""" yield warnings = [] for warning in recwarn: # pragma: no cover message = str(warning.message) # ImportWarning: Not importing directory '...' missing __init__(.py) if not ( isinstance(warning.message, ImportWarning) and message.startswith("Not importing directory ") and " missing __init__" in message ): warnings.append(f"{warning.filename}:{warning.lineno} {message}") assert not warnings