Skip to content

Commit 24da941

Browse files
committed
simplify some imports
1 parent d565670 commit 24da941

File tree

2 files changed

+16
-22
lines changed

2 files changed

+16
-22
lines changed

cwltest/plugin.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,7 @@
1717
from cwltest.compare import CompareFail, compare
1818

1919
if TYPE_CHECKING:
20-
from _pytest._code.code import ExceptionInfo, TracebackStyle
21-
from _pytest.config import Config
22-
from _pytest.config import Config as PytestConfig
23-
from _pytest.config import PytestPluginManager
24-
from _pytest.config.argparsing import Parser as PytestParser
20+
from _pytest._code.code import TracebackStyle
2521
from _pytest.nodes import Node
2622
from pluggy import HookCaller
2723

@@ -36,7 +32,7 @@ def __call__(
3632
...
3733

3834

39-
def _get_comma_separated_option(config: "Config", name: str) -> list[str]:
35+
def _get_comma_separated_option(config: pytest.Config, name: str) -> list[str]:
4036
options = config.getoption(name)
4137
if options is None:
4238
return []
@@ -195,7 +191,7 @@ def runtest(self) -> None:
195191

196192
def repr_failure(
197193
self,
198-
excinfo: "ExceptionInfo[BaseException]",
194+
excinfo: pytest.ExceptionInfo[BaseException],
199195
style: Optional["TracebackStyle"] = None,
200196
) -> str:
201197
"""
@@ -359,7 +355,7 @@ def collect(self) -> Iterator[CWLItem]:
359355
]
360356

361357

362-
def pytest_addoption(parser: "PytestParser") -> None:
358+
def pytest_addoption(parser: pytest.Parser) -> None:
363359
"""Add our options to the pytest command line."""
364360
for entry in __OPTIONS:
365361
parser.addoption(entry[0], **entry[1])
@@ -387,7 +383,7 @@ def pytest_collect_file(
387383
return None
388384

389385

390-
def pytest_configure(config: "PytestConfig") -> None:
386+
def pytest_configure(config: pytest.Config) -> None:
391387
"""Store the raw tests and the test results."""
392388
cwl_results: list[tuple[dict[str, Any], utils.TestResult]] = []
393389
config.cwl_results = cwl_results # type: ignore[attr-defined]
@@ -417,7 +413,7 @@ def pytest_sessionfinish(session: pytest.Session, exitstatus: int) -> None:
417413
utils.generate_badges(cwl_badgedir, ntotal, npassed, nfailures, nunsupported)
418414

419415

420-
def pytest_addhooks(pluginmanager: "PytestPluginManager") -> None:
416+
def pytest_addhooks(pluginmanager: pytest.PytestPluginManager) -> None:
421417
"""Register our cwl hooks."""
422418
from cwltest import hooks
423419

tests/test_plugin.py

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
import os
22
import shutil
33
from pathlib import Path
4-
from typing import TYPE_CHECKING
54

6-
from .util import get_data
5+
import pytest
76

8-
if TYPE_CHECKING:
9-
from _pytest.pytester import Pytester
7+
from .util import get_data
108

119

1210
def _load_v1_0_dir(path: Path) -> None:
@@ -20,7 +18,7 @@ def _load_v1_0_dir(path: Path) -> None:
2018
shutil.copy(get_data("tests/test-data/v1.0/args.py"), inner_dir)
2119

2220

23-
def test_include(pytester: "Pytester") -> None:
21+
def test_include(pytester: pytest.Pytester) -> None:
2422
"""Test the pytest plugin using cwltool as cwl-runner."""
2523
path = pytester.copy_example("conformance_test_v1.0.cwltest.yml")
2624
shutil.copy(
@@ -36,7 +34,7 @@ def test_include(pytester: "Pytester") -> None:
3634
result.assert_outcomes(passed=1, skipped=1)
3735

3836

39-
def test_exclude(pytester: "Pytester") -> None:
37+
def test_exclude(pytester: pytest.Pytester) -> None:
4038
"""Test the pytest plugin using cwltool as cwl-runner."""
4139
path = pytester.copy_example("conformance_test_v1.0.cwltest.yml")
4240
shutil.copy(
@@ -52,7 +50,7 @@ def test_exclude(pytester: "Pytester") -> None:
5250
result.assert_outcomes(passed=0, skipped=2)
5351

5452

55-
def test_tags(pytester: "Pytester") -> None:
53+
def test_tags(pytester: pytest.Pytester) -> None:
5654
"""Test the pytest plugin using cwltool as cwl-runner."""
5755
path = pytester.copy_example("conformance_test_v1.0.cwltest.yml")
5856
shutil.copy(
@@ -65,7 +63,7 @@ def test_tags(pytester: "Pytester") -> None:
6563
result.assert_outcomes(passed=1, skipped=1)
6664

6765

68-
def test_exclude_tags(pytester: "Pytester") -> None:
66+
def test_exclude_tags(pytester: pytest.Pytester) -> None:
6967
"""Test the pytest plugin using cwltool as cwl-runner."""
7068
path = pytester.copy_example("conformance_test_v1.0.cwltest.yml")
7169
shutil.copy(
@@ -81,7 +79,7 @@ def test_exclude_tags(pytester: "Pytester") -> None:
8179
result.assert_outcomes(skipped=2)
8280

8381

84-
def test_badgedir(pytester: "Pytester") -> None:
82+
def test_badgedir(pytester: pytest.Pytester) -> None:
8583
"""Test the pytest plugin creates the badges directory."""
8684
path = pytester.copy_example("conformance_test_v1.0.cwltest.yml")
8785
shutil.copy(
@@ -95,7 +93,7 @@ def test_badgedir(pytester: "Pytester") -> None:
9593
assert os.path.exists("cwl-badges")
9694

9795

98-
def test_no_label(pytester: "Pytester") -> None:
96+
def test_no_label(pytester: pytest.Pytester) -> None:
9997
"""Test the pytest plugin correctly extracts test names from the id field when label is missing."""
10098
path = pytester.copy_example("conformance_test_v1.2.cwltest.yaml")
10199
shutil.copy(
@@ -108,7 +106,7 @@ def test_no_label(pytester: "Pytester") -> None:
108106
result.assert_outcomes(passed=2, skipped=1)
109107

110108

111-
def test_cwltool_hook(pytester: "Pytester") -> None:
109+
def test_cwltool_hook(pytester: pytest.Pytester) -> None:
112110
"""Test the pytest plugin using cwltool as cwl-runner."""
113111
path = pytester.copy_example("conformance_test_v1.0.cwltest.yml")
114112
shutil.copy(
@@ -119,7 +117,7 @@ def test_cwltool_hook(pytester: "Pytester") -> None:
119117
result.assert_outcomes(passed=2)
120118

121119

122-
def test_no_hook(pytester: "Pytester") -> None:
120+
def test_no_hook(pytester: pytest.Pytester) -> None:
123121
"""Test the pytest plugin using the default cwl-runner."""
124122
path = pytester.copy_example("conformance_test_v1.0.cwltest.yml")
125123
_load_v1_0_dir(path)

0 commit comments

Comments
 (0)