Skip to content

Commit fc184c7

Browse files
committed
Fixes test collection
1 parent 5189eb1 commit fc184c7

File tree

3 files changed

+31
-35
lines changed

3 files changed

+31
-35
lines changed

docs/conftest.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import sys
2+
from pathlib import Path
3+
from types import MappingProxyType
4+
5+
from typing_extensions import Final
6+
7+
PYTHON_VERSION: Final = (sys.version_info.major, sys.version_info.minor)
8+
ENABLE_SINCE: Final = MappingProxyType({
9+
(3, 8): frozenset((
10+
Path('docs/pages/concept.rst'),
11+
)),
12+
})
13+
PATHS_TO_IGNORE_NOW: Final = frozenset(
14+
path.absolute()
15+
for since_python, to_ignore in ENABLE_SINCE.items()
16+
for path in to_ignore
17+
if PYTHON_VERSION < since_python
18+
)
19+
20+
21+
# TODO: remove after `phantom-types` release with `python3.7` support
22+
def pytest_collection_modifyitems(items) -> None: # noqa: WPS110
23+
"""Conditionally removes some collected docstests."""
24+
to_ignore_items = []
25+
for test_item in items:
26+
if Path(test_item.dtest.filename) in PATHS_TO_IGNORE_NOW:
27+
to_ignore_items.append(test_item)
28+
29+
for to_ignore in to_ignore_items:
30+
items.remove(to_ignore)

tests/conftest.py

Lines changed: 1 addition & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,8 @@
1-
import sys
21
from contextlib import contextmanager
3-
from pathlib import Path
4-
from types import MappingProxyType
5-
from typing import Callable, ContextManager, Iterator, Optional
6-
7-
import pytest
8-
from _pytest.config import Config
9-
from py import path as pypath
10-
from typing_extensions import Final
2+
from typing import Callable, ContextManager, Iterator
113

124
from classes._typeclass import _TypeClass # noqa: WPS450
135

14-
PYTHON_VERSION: Final = (sys.version_info.major, sys.version_info.minor)
15-
ENABLE_SINCE: Final = MappingProxyType({
16-
(3, 8): frozenset((
17-
Path('docs/pages/concept.rst'),
18-
)),
19-
})
20-
PATHS_TO_IGNORE_NOW: Final = frozenset(
21-
path.absolute()
22-
for since_python, to_ignore in ENABLE_SINCE.items()
23-
for path in to_ignore
24-
if PYTHON_VERSION < since_python
25-
)
26-
27-
28-
def pytest_ignore_collect(
29-
path: pypath.local,
30-
config: Config,
31-
) -> Optional[bool]:
32-
"""
33-
Returns ``True`` to prevent considering this path for collection.
34-
35-
This hook is consulted for all files and directories prior to calling
36-
more specific hooks. Stops at first non-None result.
37-
"""
38-
return Path(path) in PATHS_TO_IGNORE_NOW
39-
406

417
@pytest.fixture(scope='session')
428
def clear_cache() -> Callable[[_TypeClass], ContextManager]:
File renamed without changes.

0 commit comments

Comments
 (0)