Skip to content

Commit 3ee87d7

Browse files
authored
add support for pytest5 (#2)
1 parent 4227a70 commit 3ee87d7

File tree

4 files changed

+21
-11
lines changed

4 files changed

+21
-11
lines changed

noxfile.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import nox
66

77
nox.options.reuse_existing_virtualenvs = True
8-
nox.options.sessions = "lint", "tests"
8+
nox.options.sessions = "lint", "tests", "tests-pytest5"
99
locations = "pytest_test_utils", "tests.py"
1010

1111

@@ -18,6 +18,13 @@ def tests(session: nox.Session) -> None:
1818
session.run("coverage", "report", "--show-missing", "--skip-covered")
1919

2020

21+
@nox.session(python=["3.7"], name="tests-pytest5")
22+
def tests_pytest5(session: nox.Session) -> None:
23+
session.install(".[tests]")
24+
session.install("pytest==5.0.0")
25+
session.run("coverage", "run", "-m", "pytest", "tests.py")
26+
27+
2128
@nox.session
2229
def lint(session: nox.Session) -> None:
2330
session.install("pre-commit")

pytest_test_utils/pytest_plugin.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
from pathlib import Path
2-
from typing import Iterator, Type
2+
from typing import TYPE_CHECKING, Iterator, Type
33

44
import pytest
5-
from pytest import TempPathFactory
65

76
from . import TempDirFactory, TmpDir, matchers
87

8+
if TYPE_CHECKING:
9+
from pytest import MonkeyPatch, TempPathFactory
10+
911

1012
@pytest.fixture(scope="session")
11-
def tmp_dir_factory(tmp_path_factory: TempPathFactory) -> TempDirFactory:
13+
def tmp_dir_factory(tmp_path_factory: "TempPathFactory") -> TempDirFactory:
1214
return TempDirFactory(tmp_path_factory)
1315

1416

1517
@pytest.fixture
16-
def tmp_dir(
17-
tmp_path: Path, monkeypatch: pytest.MonkeyPatch
18-
) -> Iterator[TmpDir]:
18+
def tmp_dir(tmp_path: Path, monkeypatch: "MonkeyPatch") -> Iterator[TmpDir]:
1919
tmp = TmpDir(tmp_path)
2020
monkeypatch.chdir(tmp_path)
2121
yield tmp

setup.cfg

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[metadata]
22
name = pytest_test_utils
3-
version = 0.0.4
3+
version = 0.0.5
44
license = Apache License 2.0
55
license_file = LICENSE
66
url = https://github.com/iterative/pytest-test-utils
@@ -20,7 +20,7 @@ python_requires = >=3.7
2020
zip_safe = False
2121
packages = find:
2222
install_requires=
23-
pytest
23+
pytest>=5
2424

2525
[options.extras_require]
2626
tests =

tests.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,17 @@
22
from datetime import datetime, timedelta
33
from pathlib import Path
44
from types import SimpleNamespace
5-
from typing import Type
5+
from typing import TYPE_CHECKING, Type
66

77
import pytest
88

99
from pytest_test_utils import TmpDir, matchers
1010
from pytest_test_utils.matchers import Matcher
1111
from pytest_test_utils.tmp_dir_factory import TempDirFactory
1212

13+
if TYPE_CHECKING:
14+
from pytest import TempPathFactory
15+
1316
# pylint: disable=redefined-outer-name
1417

1518

@@ -81,7 +84,7 @@ def test_cat(tmp_dir: TmpDir) -> None:
8184

8285

8386
def test_tmp_dir_factory(
84-
tmp_path_factory: pytest.TempPathFactory, tmp_dir_factory: TempDirFactory
87+
tmp_path_factory: "TempPathFactory", tmp_dir_factory: TempDirFactory
8588
) -> None:
8689
assert isinstance(tmp_dir_factory, TempDirFactory)
8790
tmp_dir = tmp_dir_factory.mktemp("test-dir")

0 commit comments

Comments
 (0)