Skip to content

Commit e0bbf09

Browse files
Respect pytest config python_files when identifying pytest test modules
1 parent 2bb24d2 commit e0bbf09

3 files changed

Lines changed: 9 additions & 4 deletions

File tree

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,7 @@ decorators are extracted from the ast.
100100

101101
* Fix `PYTEST_VERSION_INFO` - by [@blueyed](https://github.com/blueyed) (#8)
102102
* Always pass `--check-untyped-defs` to mypy (#11)
103-
* Respect pytest `python_files` setting when looking at `*.py` files
104-
for mypy testing functions ()
103+
* Respect pytest config `python_files` when identifying pytest test modules ()
105104

106105
## v0.0.6 - add pytest 5.4 support
107106

tests/test_parser.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@
44
import ast
55
import sys
66
from tokenize import COMMENT, ENDMARKER, NAME, NEWLINE, NL, TokenInfo
7+
from unittest.mock import Mock
78

89
import pytest
10+
from _pytest.config import Config
911

1012
from pytest_mypy_testing.parser import (
1113
MypyTestItem,
@@ -87,4 +89,5 @@ def test_mypy_bar():
8789
)
8890

8991
monkeypatch.setattr(sys, "version_info", (3, 7, 5))
90-
parse_file(str(path))
92+
config = Mock(spec=Config)
93+
parse_file(str(path), config)

tests/test_plugin.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,10 @@ def mk_dummy_parent(tmp_path, filename, content=""):
3434

3535
config = Mock(spec=Config)
3636
config.rootdir = str(tmp_path)
37-
session = SimpleNamespace(config=config, _initialpaths=[])
37+
config.getini.return_value = ["test_*.py", "*_test.py"]
38+
session = SimpleNamespace(
39+
config=config, isinitpath=lambda p: True, _initialpaths=[]
40+
)
3841
parent = SimpleNamespace(
3942
config=config,
4043
session=session,

0 commit comments

Comments
 (0)