|
1 | 1 | from __future__ import absolute_import, division, print_function |
2 | | -import sys |
3 | 2 |
|
4 | | -from py._code.code import FormattedExcinfo |
| 3 | +import inspect |
| 4 | +import sys |
| 5 | +import warnings |
5 | 6 |
|
6 | 7 | import py |
7 | | -import warnings |
| 8 | +from py._code.code import FormattedExcinfo |
8 | 9 |
|
9 | | -import inspect |
10 | 10 | import _pytest |
| 11 | +from _pytest import nodes |
11 | 12 | from _pytest._code.code import TerminalRepr |
12 | 13 | from _pytest.compat import ( |
13 | 14 | NOTSET, exc_clear, _format_args, |
14 | 15 | getfslineno, get_real_func, |
15 | 16 | is_generator, isclass, getimfunc, |
16 | 17 | getlocation, getfuncargnames, |
17 | 18 | safe_getattr, |
| 19 | + FuncargnamesCompatAttr, |
18 | 20 | ) |
19 | 21 | from _pytest.outcomes import fail, TEST_OUTCOME |
20 | | -from _pytest.compat import FuncargnamesCompatAttr |
| 22 | + |
21 | 23 |
|
22 | 24 | from collections import OrderedDict |
23 | 25 |
|
@@ -977,8 +979,8 @@ def pytest_plugin_registered(self, plugin): |
977 | 979 | # by their test id) |
978 | 980 | if p.basename.startswith("conftest.py"): |
979 | 981 | nodeid = p.dirpath().relto(self.config.rootdir) |
980 | | - if p.sep != "/": |
981 | | - nodeid = nodeid.replace(p.sep, "/") |
| 982 | + if p.sep != nodes.SEP: |
| 983 | + nodeid = nodeid.replace(p.sep, nodes.SEP) |
982 | 984 | self.parsefactories(plugin, nodeid) |
983 | 985 |
|
984 | 986 | def _getautousenames(self, nodeid): |
@@ -1033,9 +1035,14 @@ def pytest_generate_tests(self, metafunc): |
1033 | 1035 | if faclist: |
1034 | 1036 | fixturedef = faclist[-1] |
1035 | 1037 | if fixturedef.params is not None: |
1036 | | - func_params = getattr(getattr(metafunc.function, 'parametrize', None), 'args', [[None]]) |
| 1038 | + parametrize_func = getattr(metafunc.function, 'parametrize', None) |
| 1039 | + func_params = getattr(parametrize_func, 'args', [[None]]) |
| 1040 | + func_kwargs = getattr(parametrize_func, 'kwargs', {}) |
1037 | 1041 | # skip directly parametrized arguments |
1038 | | - argnames = func_params[0] |
| 1042 | + if "argnames" in func_kwargs: |
| 1043 | + argnames = parametrize_func.kwargs["argnames"] |
| 1044 | + else: |
| 1045 | + argnames = func_params[0] |
1039 | 1046 | if not isinstance(argnames, (tuple, list)): |
1040 | 1047 | argnames = [x.strip() for x in argnames.split(",") if x.strip()] |
1041 | 1048 | if argname not in func_params and argname not in argnames: |
@@ -1123,5 +1130,5 @@ def getfixturedefs(self, argname, nodeid): |
1123 | 1130 |
|
1124 | 1131 | def _matchfactories(self, fixturedefs, nodeid): |
1125 | 1132 | for fixturedef in fixturedefs: |
1126 | | - if nodeid.startswith(fixturedef.baseid): |
| 1133 | + if nodes.ischildnode(fixturedef.baseid, nodeid): |
1127 | 1134 | yield fixturedef |
0 commit comments