From f7eabe2c40106af10c1a9245f2321a08dedf47bc Mon Sep 17 00:00:00 2001 From: CoolCat467 <52022020+CoolCat467@users.noreply.github.com> Date: Wed, 18 Oct 2023 20:02:46 -0500 Subject: [PATCH] WIP enable flake8-pytest-style --- pyproject.toml | 1 + trio/_core/_tests/test_io.py | 2 +- trio/_tests/pytest_plugin.py | 4 ++-- trio/_tests/test_deprecate.py | 2 +- trio/_tests/test_exports.py | 4 ++-- trio/_tests/test_file_io.py | 6 +++--- trio/_tests/test_path.py | 2 +- trio/_tests/test_socket.py | 2 +- 8 files changed, 12 insertions(+), 11 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 7ecbbe5f4f..bb4d1eef50 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -27,6 +27,7 @@ select = [ "F", # pyflakes "I", # isort "YTT", # flake8-2020 + "PT", # flake8-pytest-style ] extend-ignore = [ 'F403', # undefined-local-with-import-star diff --git a/trio/_core/_tests/test_io.py b/trio/_core/_tests/test_io.py index 039dfbef01..69c2d715bc 100644 --- a/trio/_core/_tests/test_io.py +++ b/trio/_core/_tests/test_io.py @@ -42,7 +42,7 @@ def drain_socket(sock: stdlib_socket.socket) -> None: RetT = TypeVar("RetT") -@pytest.fixture +@pytest.fixture() def socketpair() -> Generator[SocketPair, None, None]: pair = stdlib_socket.socketpair() for sock in pair: diff --git a/trio/_tests/pytest_plugin.py b/trio/_tests/pytest_plugin.py index bbb5093be5..bacd626339 100644 --- a/trio/_tests/pytest_plugin.py +++ b/trio/_tests/pytest_plugin.py @@ -27,12 +27,12 @@ def pytest_configure(config: pytest.Config) -> None: SKIP_OPTIONAL_IMPORTS = config.getoption("--skip-optional-imports", default=False) -@pytest.fixture +@pytest.fixture() def mock_clock() -> MockClock: return MockClock() -@pytest.fixture +@pytest.fixture() def autojump_clock() -> MockClock: return MockClock(autojump_threshold=0) diff --git a/trio/_tests/test_deprecate.py b/trio/_tests/test_deprecate.py index da548fc715..a3946eab14 100644 --- a/trio/_tests/test_deprecate.py +++ b/trio/_tests/test_deprecate.py @@ -14,7 +14,7 @@ from . import module_with_deprecations -@pytest.fixture +@pytest.fixture() def recwarn_always(recwarn: pytest.WarningsRecorder) -> pytest.WarningsRecorder: warnings.simplefilter("always") # ResourceWarnings about unclosed sockets can occur nondeterministically diff --git a/trio/_tests/test_exports.py b/trio/_tests/test_exports.py index e756e8ad69..71c9ffb198 100644 --- a/trio/_tests/test_exports.py +++ b/trio/_tests/test_exports.py @@ -113,7 +113,7 @@ def iter_modules( # they might be using a newer version of Python with additional symbols which # won't be reflected in trio.socket, and this shouldn't cause downstream test # runs to start failing. -@pytest.mark.redistributors_should_skip +@pytest.mark.redistributors_should_skip() # Static analysis tools often have trouble with alpha releases, where Python's # internals are in flux, grammar may not have settled down, etc. @pytest.mark.skipif( @@ -263,7 +263,7 @@ def no_underscores(symbols): # modules, instead of once per class. @slow # see comment on test_static_tool_sees_all_symbols -@pytest.mark.redistributors_should_skip +@pytest.mark.redistributors_should_skip() # Static analysis tools often have trouble with alpha releases, where Python's # internals are in flux, grammar may not have settled down, etc. @pytest.mark.skipif( diff --git a/trio/_tests/test_file_io.py b/trio/_tests/test_file_io.py index 3913d25298..109c61fa07 100644 --- a/trio/_tests/test_file_io.py +++ b/trio/_tests/test_file_io.py @@ -14,17 +14,17 @@ from trio._file_io import _FILE_ASYNC_METHODS, _FILE_SYNC_ATTRS, AsyncIOWrapper -@pytest.fixture +@pytest.fixture() def path(tmp_path: pathlib.Path) -> str: return os.fspath(tmp_path / "test") -@pytest.fixture +@pytest.fixture() def wrapped(): return mock.Mock(spec_set=io.StringIO) -@pytest.fixture +@pytest.fixture() def async_file(wrapped): return trio.wrap_file(wrapped) diff --git a/trio/_tests/test_path.py b/trio/_tests/test_path.py index b0b16f9e4f..98eb655c18 100644 --- a/trio/_tests/test_path.py +++ b/trio/_tests/test_path.py @@ -12,7 +12,7 @@ from trio._path import AsyncAutoWrapperType as WrapperType -@pytest.fixture +@pytest.fixture() def path(tmp_path: pathlib.Path) -> trio.Path: return trio.Path(tmp_path / "test") diff --git a/trio/_tests/test_socket.py b/trio/_tests/test_socket.py index 40ffefb8cd..5fc7516728 100644 --- a/trio/_tests/test_socket.py +++ b/trio/_tests/test_socket.py @@ -69,7 +69,7 @@ def getaddrinfo(self, *args: Any, **kwargs: Any) -> getaddrinfoResponse | str: raise RuntimeError(f"gai called with unexpected arguments {bound}") -@pytest.fixture +@pytest.fixture() def monkeygai(monkeypatch: pytest.MonkeyPatch) -> MonkeypatchedGAI: controller = MonkeypatchedGAI(stdlib_socket.getaddrinfo) monkeypatch.setattr(stdlib_socket, "getaddrinfo", controller.getaddrinfo)