From 44d224ee3bda765ddcaf86b1a88d68b33c98471e Mon Sep 17 00:00:00 2001 From: Dmitry Semenov Date: Sun, 11 Sep 2022 19:02:43 +0300 Subject: [PATCH 1/9] Convert deprecated type comments to type hints --- pytest_snapshot/plugin.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pytest_snapshot/plugin.py b/pytest_snapshot/plugin.py index a8699c2..1c46bb1 100644 --- a/pytest_snapshot/plugin.py +++ b/pytest_snapshot/plugin.py @@ -68,12 +68,12 @@ def _file_decode(data: bytes) -> str: class Snapshot: - _snapshot_update = None # type: bool - _allow_snapshot_deletion = None # type: bool - _created_snapshots = None # type: List[Path] - _updated_snapshots = None # type: List[Path] - _snapshots_to_delete = None # type: List[Path] - _snapshot_dir = None # type: Path + _snapshot_update: bool + _allow_snapshot_deletion: bool + _created_snapshots: List[Path] + _updated_snapshots: List[Path] + _snapshots_to_delete: List[Path] + _snapshot_dir: Path def __init__(self, snapshot_update: bool, allow_snapshot_deletion: bool, snapshot_dir: Path): self._snapshot_update = snapshot_update From 10d7aa419627b18b744a67d86821c881a31735a7 Mon Sep 17 00:00:00 2001 From: Dmitry Semenov Date: Sun, 11 Sep 2022 19:58:26 +0300 Subject: [PATCH 2/9] Add more type annotations --- pytest_snapshot/_utils.py | 9 +++++---- pytest_snapshot/plugin.py | 12 +++++++----- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/pytest_snapshot/_utils.py b/pytest_snapshot/_utils.py index 1236317..96c78cf 100644 --- a/pytest_snapshot/_utils.py +++ b/pytest_snapshot/_utils.py @@ -1,6 +1,7 @@ import os import re from pathlib import Path +from typing import List, Tuple import pytest @@ -44,7 +45,7 @@ def might_be_valid_filename(s: str) -> bool: ) -def simple_version_parse(version: str): +def simple_version_parse(version: str) -> Tuple[int, int, int]: """ Returns a 3 tuple of the versions major, minor, and patch. Raises a value error if the version string is unsupported. @@ -75,7 +76,7 @@ def _pytest_expected_on_right() -> bool: return pytest_version >= (5, 4, 0) -def flatten_dict(d: dict): +def flatten_dict(d: dict) -> List[Tuple[List, ...]]: """ Returns the flattened dict representation of the given dict. @@ -96,7 +97,7 @@ def flatten_dict(d: dict): return result -def _flatten_dict(obj, result, prefix): +def _flatten_dict(obj: dict, result: list, prefix: list) -> None: if type(obj) is dict: for k, v in obj.items(): prefix.append(k) @@ -106,7 +107,7 @@ def _flatten_dict(obj, result, prefix): result.append((list(prefix), obj)) -def flatten_filesystem_dict(d): +def flatten_filesystem_dict(d: dict) -> dict: """ Returns the flattened dict of a nested dictionary structure describing a filesystem. diff --git a/pytest_snapshot/plugin.py b/pytest_snapshot/plugin.py index 1c46bb1..e7de43f 100644 --- a/pytest_snapshot/plugin.py +++ b/pytest_snapshot/plugin.py @@ -2,7 +2,7 @@ import os import re from pathlib import Path -from typing import List, Union +from typing import Any, Callable, List, Tuple, Union import pytest import _pytest.python @@ -36,7 +36,7 @@ def snapshot(request): yield snapshot -def _assert_equal(value, snapshot) -> None: +def _assert_equal(value: Any, snapshot: Any) -> None: if _pytest_expected_on_right(): assert value == snapshot else: @@ -135,7 +135,9 @@ def _snapshot_path(self, snapshot_name: Union[str, Path]) -> Path: return snapshot_path - def _get_compare_encode_decode(self, value: Union[str, bytes]): + def _get_compare_encode_decode(self, value: Union[str, bytes]) -> Tuple[ + Callable[[Any, Any], None], Callable[..., bytes], Callable[..., str] + ]: """ Returns a 3-tuple of a compare function, an encoding function, and a decoding function. @@ -151,7 +153,7 @@ def _get_compare_encode_decode(self, value: Union[str, bytes]): else: raise TypeError('value must be str or bytes') - def assert_match(self, value: Union[str, bytes], snapshot_name: Union[str, Path]): + def assert_match(self, value: Union[str, bytes], snapshot_name: Union[str, Path]) -> None: """ Asserts that ``value`` equals the current value of the snapshot with the given ``snapshot_name``. @@ -202,7 +204,7 @@ def assert_match(self, value: Union[str, bytes], snapshot_name: Union[str, Path] "snapshot {} doesn't exist. (run pytest with --snapshot-update to create it)".format( shorten_path(snapshot_path))) - def assert_match_dir(self, dir_dict: dict, snapshot_dir_name: Union[str, Path]): + def assert_match_dir(self, dir_dict: dict, snapshot_dir_name: Union[str, Path]) -> None: """ Asserts that the values in dir_dict equal the current values in the given snapshot directory. From 80a2dd42bc88f39533c3b25a75abe481653aacf8 Mon Sep 17 00:00:00 2001 From: Dmitry Semenov Date: Sun, 11 Sep 2022 20:19:26 +0300 Subject: [PATCH 3/9] Create py.typed marker --- MANIFEST.in | 1 + pytest_snapshot/py.typed | 0 setup.cfg | 2 ++ 3 files changed, 3 insertions(+) create mode 100644 pytest_snapshot/py.typed diff --git a/MANIFEST.in b/MANIFEST.in index 1ade348..a6e1af8 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,5 +1,6 @@ include LICENSE include README.rst +include pytest_snapshot/py.typed recursive-exclude * __pycache__ recursive-exclude * *.py[co] diff --git a/pytest_snapshot/py.typed b/pytest_snapshot/py.typed new file mode 100644 index 0000000..e69de29 diff --git a/setup.cfg b/setup.cfg index cfe1144..a019c0c 100644 --- a/setup.cfg +++ b/setup.cfg @@ -28,6 +28,8 @@ classifiers = [options] packages = pytest_snapshot +zip_safe = False +include_package_data = True python_requires = >=3.5 install_requires = pytest >= 3.0.0 From 27965a9dfee706245f85b84b2297aeece09a6325 Mon Sep 17 00:00:00 2001 From: Dmitry Semenov Date: Tue, 6 Dec 2022 19:24:51 +0300 Subject: [PATCH 4/9] Add more type annotations --- pytest_snapshot/plugin.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/pytest_snapshot/plugin.py b/pytest_snapshot/plugin.py index e7de43f..74f2d3b 100644 --- a/pytest_snapshot/plugin.py +++ b/pytest_snapshot/plugin.py @@ -2,17 +2,18 @@ import os import re from pathlib import Path -from typing import Any, Callable, List, Tuple, Union +from typing import Any, Callable, Iterator, List, Optional, Tuple, Union import pytest import _pytest.python +import _pytest.config.argparsing from pytest_snapshot._utils import shorten_path, get_valid_filename, _pytest_expected_on_right, flatten_filesystem_dict PARAMETRIZED_TEST_REGEX = re.compile(r'^.*?\[(.*)]$') -def pytest_addoption(parser): +def pytest_addoption(parser: _pytest.config.argparsing.Parser): group = parser.getgroup('snapshot') group.addoption( '--snapshot-update', @@ -27,7 +28,9 @@ def pytest_addoption(parser): @pytest.fixture -def snapshot(request): +def snapshot(request: pytest.FixtureRequest) -> Iterator["Snapshot"]: + # FIXME Properly handle different node type + assert isinstance(request.node, pytest.Function) default_snapshot_dir = _get_default_snapshot_dir(request.node) with Snapshot(request.config.option.snapshot_update, @@ -86,7 +89,7 @@ def __init__(self, snapshot_update: bool, allow_snapshot_deletion: bool, snapsho def __enter__(self): return self - def __exit__(self, exc_type, exc_val, exc_tb): + def __exit__(self, *_: Any): if self._created_snapshots or self._updated_snapshots or self._snapshots_to_delete: message_lines = ['Snapshot directory was modified: {}'.format(shorten_path(self.snapshot_dir)), ' (verify that the changes are expected before committing them to version control)'] @@ -119,7 +122,7 @@ def snapshot_dir(self): def snapshot_dir(self, value): self._snapshot_dir = Path(value).absolute() - def _snapshot_path(self, snapshot_name: Union[str, Path]) -> Path: + def _snapshot_path(self, snapshot_name: Union[str, os.PathLike[str]]) -> Path: """ Returns the absolute path to the given snapshot. """ @@ -187,6 +190,7 @@ def assert_match(self, value: Union[str, bytes], snapshot_name: Union[str, Path] else: if encoded_expected_value is not None: expected_value = decode(encoded_expected_value) + snapshot_diff_msg: Optional[str] try: compare(value, expected_value) except AssertionError as e: From 5f07af56306e12458b4909089ac2d725bdfda15a Mon Sep 17 00:00:00 2001 From: Dmitry Semenov Date: Tue, 6 Dec 2022 20:38:02 +0300 Subject: [PATCH 5/9] Add more complex type annotations Code suggested by @mjpieters --- pytest_snapshot/_utils.py | 34 ++++++++++++++++++++-------------- pytest_snapshot/plugin.py | 28 ++++++++++++++++++---------- 2 files changed, 38 insertions(+), 24 deletions(-) diff --git a/pytest_snapshot/_utils.py b/pytest_snapshot/_utils.py index 96c78cf..68cef84 100644 --- a/pytest_snapshot/_utils.py +++ b/pytest_snapshot/_utils.py @@ -1,13 +1,17 @@ import os import re from pathlib import Path -from typing import List, Tuple +from typing import Dict, List, Tuple, TypeVar, Union, cast import pytest SIMPLE_VERSION_REGEX = re.compile(r'([0-9]+)\.([0-9]+)\.([0-9]+)') ILLEGAL_FILENAME_CHARS = r'\/:*?"<>|' +_K = TypeVar("_K") +_V = TypeVar("_V") +_RecursiveDict = Dict[_K, Union["_RecursiveDict", _V]] + def shorten_path(path: Path) -> Path: """ @@ -45,7 +49,7 @@ def might_be_valid_filename(s: str) -> bool: ) -def simple_version_parse(version: str) -> Tuple[int, int, int]: +def simple_version_parse(version: str) -> Tuple[int, ...]: """ Returns a 3 tuple of the versions major, minor, and patch. Raises a value error if the version string is unsupported. @@ -76,7 +80,7 @@ def _pytest_expected_on_right() -> bool: return pytest_version >= (5, 4, 0) -def flatten_dict(d: dict) -> List[Tuple[List, ...]]: +def flatten_dict(d: _RecursiveDict[_K, _V]) -> List[Tuple[List[_K], _V]]: """ Returns the flattened dict representation of the given dict. @@ -92,22 +96,24 @@ def flatten_dict(d: dict) -> List[Tuple[List, ...]]: [(['a'], 1), (['b', 'c'], 2)] """ assert type(d) is dict - result = [] - _flatten_dict(d, result, []) + result: List[Tuple[List[_K], _V]] = [] + _flatten_dict(d, result, []) # type: ignore[misc] return result -def _flatten_dict(obj: dict, result: list, prefix: list) -> None: - if type(obj) is dict: - for k, v in obj.items(): - prefix.append(k) - _flatten_dict(v, result, prefix) - prefix.pop() - else: - result.append((list(prefix), obj)) +def _flatten_dict( + obj: _RecursiveDict[_K, _V], result: List[Tuple[List[_K], _V]], prefix: List[_K] +) -> None: + for k, v in obj.items(): + prefix.append(k) + if type(v) is dict: + _flatten_dict(cast(_RecursiveDict[_K, _V], v), result, prefix) + else: + result.append((list(prefix), cast(_V, v))) + prefix.pop() -def flatten_filesystem_dict(d: dict) -> dict: +def flatten_filesystem_dict(d: _RecursiveDict[str, _V]) -> Dict[str, _V]: """ Returns the flattened dict of a nested dictionary structure describing a filesystem. diff --git a/pytest_snapshot/plugin.py b/pytest_snapshot/plugin.py index 74f2d3b..e27ac38 100644 --- a/pytest_snapshot/plugin.py +++ b/pytest_snapshot/plugin.py @@ -2,13 +2,14 @@ import os import re from pathlib import Path -from typing import Any, Callable, Iterator, List, Optional, Tuple, Union +from typing import Any, AnyStr, Callable, Iterator, List, Optional, Tuple, Union import pytest import _pytest.python import _pytest.config.argparsing -from pytest_snapshot._utils import shorten_path, get_valid_filename, _pytest_expected_on_right, flatten_filesystem_dict +from pytest_snapshot._utils import shorten_path, get_valid_filename, _pytest_expected_on_right +from pytest_snapshot._utils import flatten_filesystem_dict, _RecursiveDict PARAMETRIZED_TEST_REGEX = re.compile(r'^.*?\[(.*)]$') @@ -39,7 +40,7 @@ def snapshot(request: pytest.FixtureRequest) -> Iterator["Snapshot"]: yield snapshot -def _assert_equal(value: Any, snapshot: Any) -> None: +def _assert_equal(value: AnyStr, snapshot: AnyStr) -> None: if _pytest_expected_on_right(): assert value == snapshot else: @@ -138,8 +139,10 @@ def _snapshot_path(self, snapshot_name: Union[str, os.PathLike[str]]) -> Path: return snapshot_path - def _get_compare_encode_decode(self, value: Union[str, bytes]) -> Tuple[ - Callable[[Any, Any], None], Callable[..., bytes], Callable[..., str] + def _get_compare_encode_decode(self, value: AnyStr) -> Tuple[ + Callable[[AnyStr, AnyStr], None], + Callable[[AnyStr], bytes], + Callable[[bytes], AnyStr] ]: """ Returns a 3-tuple of a compare function, an encoding function, and a decoding function. @@ -152,11 +155,12 @@ def _get_compare_encode_decode(self, value: Union[str, bytes]) -> Tuple[ if isinstance(value, str): return _assert_equal, _file_encode, _file_decode elif isinstance(value, bytes): - return _assert_equal, lambda x: x, lambda x: x + noop: Callable[[bytes], bytes] = lambda x: x + return _assert_equal, noop, noop else: raise TypeError('value must be str or bytes') - def assert_match(self, value: Union[str, bytes], snapshot_name: Union[str, Path]) -> None: + def assert_match(self, value: AnyStr, snapshot_name: Union[str, os.PathLike[str]]) -> None: """ Asserts that ``value`` equals the current value of the snapshot with the given ``snapshot_name``. @@ -208,7 +212,11 @@ def assert_match(self, value: Union[str, bytes], snapshot_name: Union[str, Path] "snapshot {} doesn't exist. (run pytest with --snapshot-update to create it)".format( shorten_path(snapshot_path))) - def assert_match_dir(self, dir_dict: dict, snapshot_dir_name: Union[str, Path]) -> None: + def assert_match_dir( + self, + dir_dict: _RecursiveDict[str, Union[bytes, str]], + snapshot_dir_name: Union[str, os.PathLike[str]] + ) -> None: """ Asserts that the values in dir_dict equal the current values in the given snapshot directory. @@ -220,7 +228,7 @@ def assert_match_dir(self, dir_dict: dict, snapshot_dir_name: Union[str, Path]) raise TypeError('dir_dict must be a dictionary') snapshot_dir_path = self._snapshot_path(snapshot_dir_name) - values_by_filename = flatten_filesystem_dict(dir_dict) + values_by_filename = flatten_filesystem_dict(dir_dict) # type: ignore[misc] if snapshot_dir_path.is_dir(): existing_names = {p.relative_to(snapshot_dir_path).as_posix() for p in snapshot_dir_path.rglob('*') if p.is_file()} @@ -248,7 +256,7 @@ def assert_match_dir(self, dir_dict: dict, snapshot_dir_name: Union[str, Path]) # Call assert_match to add, update, or assert equality for all snapshot files in the directory. for name, value in values_by_filename.items(): - self.assert_match(value, snapshot_dir_path.joinpath(name)) + self.assert_match(value, snapshot_dir_path.joinpath(name)) # pyright: ignore def _get_default_snapshot_dir(node: _pytest.python.Function) -> Path: From d758a3358b09da18cc7363a8886b54fbb3615218 Mon Sep 17 00:00:00 2001 From: Dmitry Semenov Date: Tue, 6 Dec 2022 22:28:29 +0300 Subject: [PATCH 6/9] Add type checking tox environments --- tox.ini | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index 34c4df8..d2051b7 100644 --- a/tox.ini +++ b/tox.ini @@ -7,6 +7,8 @@ envlist = # Coverage is slow in pypy pypy3-pytest{3,4,5,6,} flake8 + pyright + mypy [testenv] deps = @@ -33,6 +35,17 @@ skip_install = true deps = flake8 commands = flake8 pytest_snapshot setup.py tests +[testenv:pyright] +deps = pyright +usedevelop = false +commands = pyright --verifytypes pytest_snapshot --ignoreexternal + +[testenv:mypy] +deps = + mypy + py +commands = mypy -p pytest_snapshot + [flake8] max-line-length = 120 @@ -43,6 +56,6 @@ python = 3.7: py37 3.8: py38 3.9: py39 - 3.10: py310, flake8 + 3.10: py310, flake8, mypy, pyright 3: py3 pypy-3: pypy3 From c73632c98ca1a9bea6a719151e11c1b66c70e1f6 Mon Sep 17 00:00:00 2001 From: Dmitry Semenov Date: Tue, 6 Dec 2022 22:41:55 +0300 Subject: [PATCH 7/9] Add final type annotations --- pytest_snapshot/plugin.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pytest_snapshot/plugin.py b/pytest_snapshot/plugin.py index e27ac38..685d0b0 100644 --- a/pytest_snapshot/plugin.py +++ b/pytest_snapshot/plugin.py @@ -14,7 +14,7 @@ PARAMETRIZED_TEST_REGEX = re.compile(r'^.*?\[(.*)]$') -def pytest_addoption(parser: _pytest.config.argparsing.Parser): +def pytest_addoption(parser: _pytest.config.argparsing.Parser) -> None: group = parser.getgroup('snapshot') group.addoption( '--snapshot-update', @@ -87,10 +87,10 @@ def __init__(self, snapshot_update: bool, allow_snapshot_deletion: bool, snapsho self._updated_snapshots = [] self._snapshots_to_delete = [] - def __enter__(self): + def __enter__(self) -> "Snapshot": return self - def __exit__(self, *_: Any): + def __exit__(self, *_: Any) -> None: if self._created_snapshots or self._updated_snapshots or self._snapshots_to_delete: message_lines = ['Snapshot directory was modified: {}'.format(shorten_path(self.snapshot_dir)), ' (verify that the changes are expected before committing them to version control)'] @@ -116,11 +116,11 @@ def __exit__(self, *_: Any): pytest.fail('\n'.join(message_lines), pytrace=False) @property - def snapshot_dir(self): + def snapshot_dir(self) -> Path: return self._snapshot_dir @snapshot_dir.setter - def snapshot_dir(self, value): + def snapshot_dir(self, value: Union[str, os.PathLike[str], Path]) -> None: self._snapshot_dir = Path(value).absolute() def _snapshot_path(self, snapshot_name: Union[str, os.PathLike[str]]) -> Path: From ac38e452ded599410625ebfabb74f2d3736404f2 Mon Sep 17 00:00:00 2001 From: Joseph Roitman Date: Sat, 11 Nov 2023 02:31:33 +0200 Subject: [PATCH 8/9] Fix imports from earlier versions of pytest. --- pytest_snapshot/plugin.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/pytest_snapshot/plugin.py b/pytest_snapshot/plugin.py index 685d0b0..bfb77c7 100644 --- a/pytest_snapshot/plugin.py +++ b/pytest_snapshot/plugin.py @@ -5,8 +5,16 @@ from typing import Any, AnyStr, Callable, Iterator, List, Optional, Tuple, Union import pytest -import _pytest.python -import _pytest.config.argparsing + +try: + from pytest import Parser as _Parser +except ImportError: + from _pytest.config.argparsing import Parser as _Parser + +try: + from pytest import FixtureRequest as _FixtureRequest +except ImportError: + from _pytest.fixtures import FixtureRequest as _FixtureRequest from pytest_snapshot._utils import shorten_path, get_valid_filename, _pytest_expected_on_right from pytest_snapshot._utils import flatten_filesystem_dict, _RecursiveDict @@ -14,7 +22,7 @@ PARAMETRIZED_TEST_REGEX = re.compile(r'^.*?\[(.*)]$') -def pytest_addoption(parser: _pytest.config.argparsing.Parser) -> None: +def pytest_addoption(parser: _Parser) -> None: group = parser.getgroup('snapshot') group.addoption( '--snapshot-update', @@ -29,7 +37,7 @@ def pytest_addoption(parser: _pytest.config.argparsing.Parser) -> None: @pytest.fixture -def snapshot(request: pytest.FixtureRequest) -> Iterator["Snapshot"]: +def snapshot(request: _FixtureRequest) -> Iterator["Snapshot"]: # FIXME Properly handle different node type assert isinstance(request.node, pytest.Function) default_snapshot_dir = _get_default_snapshot_dir(request.node) @@ -120,7 +128,7 @@ def snapshot_dir(self) -> Path: return self._snapshot_dir @snapshot_dir.setter - def snapshot_dir(self, value: Union[str, os.PathLike[str], Path]) -> None: + def snapshot_dir(self, value: Union[str, os.PathLike[str]]) -> None: self._snapshot_dir = Path(value).absolute() def _snapshot_path(self, snapshot_name: Union[str, os.PathLike[str]]) -> Path: @@ -259,7 +267,7 @@ def assert_match_dir( self.assert_match(value, snapshot_dir_path.joinpath(name)) # pyright: ignore -def _get_default_snapshot_dir(node: _pytest.python.Function) -> Path: +def _get_default_snapshot_dir(node: pytest.Function) -> Path: """ Returns the default snapshot directory for the pytest test. """ From f9da3004e0fd808b3aa0d4d4c768c3a83afb9c64 Mon Sep 17 00:00:00 2001 From: Joseph Roitman Date: Sat, 11 Nov 2023 05:16:21 +0200 Subject: [PATCH 9/9] Fix os.PathLike in Python <3.9. Remove Python 3.5 tests. --- .github/workflows/CI.yml | 4 ---- pytest_snapshot/plugin.py | 8 ++++---- tox.ini | 3 +-- 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 58b25a9..2a60c35 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -35,10 +35,6 @@ jobs: os: macos-latest # macos builds sometimes get stuck starting "python -m tox". experimental: true - - python-version: 3.5 - # Latest os version that supports Python 3.5 - os: ubuntu-20.04 - experimental: false - python-version: 3.6 # Latest os version that supports Python 3.6 os: ubuntu-20.04 diff --git a/pytest_snapshot/plugin.py b/pytest_snapshot/plugin.py index bfb77c7..02b6eed 100644 --- a/pytest_snapshot/plugin.py +++ b/pytest_snapshot/plugin.py @@ -128,10 +128,10 @@ def snapshot_dir(self) -> Path: return self._snapshot_dir @snapshot_dir.setter - def snapshot_dir(self, value: Union[str, os.PathLike[str]]) -> None: + def snapshot_dir(self, value: Union[str, 'os.PathLike[str]']) -> None: self._snapshot_dir = Path(value).absolute() - def _snapshot_path(self, snapshot_name: Union[str, os.PathLike[str]]) -> Path: + def _snapshot_path(self, snapshot_name: Union[str, 'os.PathLike[str]']) -> Path: """ Returns the absolute path to the given snapshot. """ @@ -168,7 +168,7 @@ def _get_compare_encode_decode(self, value: AnyStr) -> Tuple[ else: raise TypeError('value must be str or bytes') - def assert_match(self, value: AnyStr, snapshot_name: Union[str, os.PathLike[str]]) -> None: + def assert_match(self, value: AnyStr, snapshot_name: Union[str, 'os.PathLike[str]']) -> None: """ Asserts that ``value`` equals the current value of the snapshot with the given ``snapshot_name``. @@ -223,7 +223,7 @@ def assert_match(self, value: AnyStr, snapshot_name: Union[str, os.PathLike[str] def assert_match_dir( self, dir_dict: _RecursiveDict[str, Union[bytes, str]], - snapshot_dir_name: Union[str, os.PathLike[str]] + snapshot_dir_name: Union[str, 'os.PathLike[str]'] ) -> None: """ Asserts that the values in dir_dict equal the current values in the given snapshot directory. diff --git a/tox.ini b/tox.ini index 31466e3..f548c16 100644 --- a/tox.ini +++ b/tox.ini @@ -3,7 +3,7 @@ envlist = # Pytest <6.2.5 not supported on Python >=3.10 py{36,37,38,39}-pytest{3,4,5}-coverage - py{35,36,37,38,39,310,311,312,3}-pytest{6,}-coverage + py{36,37,38,39,310,311,312,3}-pytest{6,}-coverage # Coverage is slow in pypy pypy3-pytest{6,} flake8 @@ -49,7 +49,6 @@ max-line-length = 120 [gh-actions] python = - 3.5: py35 3.6: py36 3.7: py37 3.8: py38