diff --git a/conftest.py b/conftest.py index 4586a81..c3fbd90 100644 --- a/conftest.py +++ b/conftest.py @@ -1,23 +1,13 @@ +import builtins import sys -import pytest +def pytest_configure(): + add_future_flags() -class Flags: - warn_default_encoding = 0 - def __getattr__(self, *args): - return getattr(sys.flags, *args) - - -@pytest.fixture(scope="session") -def monkeysession(): - with pytest.MonkeyPatch.context() as mp: - yield mp - - -@pytest.fixture(scope="session", autouse=True) -def future_flags(monkeysession): +def add_future_flags(): if sys.version_info > (3, 10): return - monkeysession.setattr(sys, 'flags', Flags()) + + builtins.EncodingWarning = type('EncodingWarning', (Warning,), {}) diff --git a/tests/test_zipp.py b/tests/test_zipp.py index 893761e..ee09397 100644 --- a/tests/test_zipp.py +++ b/tests/test_zipp.py @@ -187,7 +187,7 @@ def test_open_encoding_errors(self): f.read() @unittest.skipIf( - not sys.flags.warn_default_encoding, + not getattr(sys.flags, 'warn_default_encoding', 0), "Requires warn_default_encoding", ) @pass_alpharep