Skip to content

Commit 73c723b

Browse files
authored
Merge pull request #75 from dmtucker/nodeid
Add a configurable name to MypyItem node IDs
2 parents e1e4ebd + 1d66e7a commit 73c723b

File tree

4 files changed

+30
-25
lines changed

4 files changed

+30
-25
lines changed

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ def read(fname):
3232
python_requires='~=3.4',
3333
install_requires=[
3434
'filelock>=3.0',
35-
'pytest>=2.8,<4.7; python_version<"3.5"',
36-
'pytest>=2.8; python_version>="3.5"',
35+
'pytest>=3.5,<4.7; python_version<"3.5"',
36+
'pytest>=3.5; python_version>="3.5"',
3737
'mypy>=0.500,<0.700; python_version<"3.5"',
3838
'mypy>=0.500; python_version>="3.5" and python_version<"3.8"',
3939
'mypy>=0.700; python_version>="3.8"',

src/pytest_mypy.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111

1212
mypy_argv = []
13+
nodeid_name = 'mypy'
1314

1415

1516
def pytest_addoption(parser):
@@ -77,7 +78,14 @@ def pytest_collect_file(path, parent):
7778
parent.config.option.mypy,
7879
parent.config.option.mypy_ignore_missing_imports,
7980
]):
80-
return MypyItem(path, parent)
81+
item = MypyItem(path, parent)
82+
if nodeid_name:
83+
item = MypyItem(
84+
path,
85+
parent,
86+
nodeid='::'.join([item.nodeid, nodeid_name]),
87+
)
88+
return item
8189
return None
8290

8391

tests/test_pytest_mypy.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,19 @@ def pytest_configure(config):
145145
assert result.ret == 0
146146

147147

148+
def test_api_nodeid_name(testdir, xdist_args):
149+
"""Ensure that the plugin can be configured in a conftest.py."""
150+
nodeid_name = 'UnmistakableNodeIDName'
151+
testdir.makepyfile(conftest='''
152+
def pytest_configure(config):
153+
plugin = config.pluginmanager.getplugin('mypy')
154+
plugin.nodeid_name = '{}'
155+
'''.format(nodeid_name))
156+
result = testdir.runpytest_subprocess('--mypy', '--verbose', *xdist_args)
157+
result.stdout.fnmatch_lines(['*conftest.py::' + nodeid_name + '*'])
158+
assert result.ret == 0
159+
160+
148161
def test_pytest_collection_modifyitems(testdir, xdist_args):
149162
testdir.makepyfile(conftest='''
150163
def pytest_collection_modifyitems(session, config, items):

tox.ini

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,15 @@
33
min_version = 3.7.0
44
isolated_build = true
55
envlist =
6-
py34-pytest{2.8, 2.x, 3.0, 3.x, 4.0, 4.x}-mypy{0.50, 0.5x, 0.60, 0.6x}
7-
py35-pytest{2.8, 2.x, 3.0, 3.x, 4.0, 4.x, 5.0, 5.x}-mypy{0.50, 0.5x, 0.60, 0.6x, 0.70, 0.7x}
8-
py36-pytest{2.8, 2.x, 3.0, 3.x, 4.0, 4.x, 5.0, 5.x}-mypy{0.50, 0.5x, 0.60, 0.6x, 0.70, 0.7x}
9-
py37-pytest{2.8, 2.x, 3.0, 3.x, 4.0, 4.x, 5.0, 5.x}-mypy{0.50, 0.5x, 0.60, 0.6x, 0.70, 0.7x}
10-
py38-pytest{2.8, 2.x, 3.0, 3.x, 4.0, 4.x, 5.0, 5.x}-mypy{0.71, 0.7x}
6+
py34-pytest{3.5, 3.x, 4.0, 4.x}-mypy{0.50, 0.5x, 0.60, 0.6x}
7+
py35-pytest{3.5, 3.x, 4.0, 4.x, 5.0, 5.x}-mypy{0.50, 0.5x, 0.60, 0.6x, 0.70, 0.7x}
8+
py36-pytest{3.5, 3.x, 4.0, 4.x, 5.0, 5.x}-mypy{0.50, 0.5x, 0.60, 0.6x, 0.70, 0.7x}
9+
py37-pytest{3.5, 3.x, 4.0, 4.x, 5.0, 5.x}-mypy{0.50, 0.5x, 0.60, 0.6x, 0.70, 0.7x}
10+
py38-pytest{3.5, 3.x, 4.0, 4.x, 5.0, 5.x}-mypy{0.71, 0.7x}
1111
flake8
1212

1313
[testenv]
1414
deps =
15-
pytest2.8: pytest ~= 2.8.0
16-
pytest2.8: pytest-xdist < 1.18.0
17-
pytest2.x: pytest ~= 2.8
18-
pytest2.x: pytest-xdist < 1.18.0
19-
pytest3.0: pytest ~= 3.0.0
20-
pytest3.0: pytest-xdist < 1.19.0
21-
pytest3.1: pytest ~= 3.1.0
22-
pytest3.1: pytest-xdist < 1.19.0
23-
pytest3.2: pytest ~= 3.2.0
24-
pytest3.2: pytest-xdist < 1.19.0
25-
pytest3.3: attrs < 19.2.0 # https://github.com/pytest-dev/pytest/issues/3223
26-
pytest3.3: pytest ~= 3.3.0
27-
pytest3.3: pytest-xdist < 1.19.0
28-
pytest3.4: attrs < 19.2.0 # https://github.com/pytest-dev/pytest/issues/3223
29-
pytest3.4: pytest ~= 3.4.0
30-
pytest3.4: pytest-xdist < 1.19.0
3115
pytest3.5: pytest ~= 3.5.0
3216
pytest3.5: pytest-xdist < 1.19.0
3317
pytest3.6: pytest ~= 3.6.0
@@ -40,7 +24,7 @@ deps =
4024
pytest3.9: pytest-xdist < 1.28.0
4125
pytest3.10: pytest ~= 3.10.0
4226
pytest3.10: pytest-xdist < 1.28.0
43-
pytest3.x: pytest ~= 3.0
27+
pytest3.x: pytest ~= 3.5
4428
pytest3.x: pytest-xdist < 1.28.0
4529
pytest4.0: attrs < 19.2.0 # https://github.com/pytest-dev/pytest/issues/5900
4630
pytest4.0: pytest ~= 4.0.0

0 commit comments

Comments
 (0)