Skip to content

Commit

Permalink
Due to mypy, it's not possible to patch the value, so just be lenient…
Browse files Browse the repository at this point in the history
… in access.
  • Loading branch information
jaraco committed Jan 27, 2023
1 parent c2b986c commit 2d7b6c6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 17 deletions.
22 changes: 6 additions & 16 deletions conftest.py
Original file line number Diff line number Diff line change
@@ -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,), {})
2 changes: 1 addition & 1 deletion tests/test_zipp.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 2d7b6c6

Please sign in to comment.