-
Notifications
You must be signed in to change notification settings - Fork 237
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
8 changed files
with
59 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
"""Provides compatibility with different pytest versions.""" | ||
|
||
from inspect import signature | ||
|
||
__GETFIXTUREDEFS_2ND_PAR_IS_STR = None | ||
|
||
|
||
def getfixturedefs(fixturemanager, name, item): | ||
"""Calls FixtureManager.getfixturedefs in a way compatible with Python | ||
versions before and after the change described in pytest-dev/pytest#11785. | ||
""" | ||
getfixturedefs = fixturemanager.getfixturedefs | ||
itemarg = __resolve_getfixturedefs_2nd_arg(getfixturedefs, item) | ||
return getfixturedefs(name, itemarg) | ||
|
||
|
||
def __resolve_getfixturedefs_2nd_arg(getfixturedefs, item): | ||
# Starting from pytest 8.1, getfixturedefs requires the item itself. | ||
# In earlier versions it requires the nodeid string. | ||
return item.nodeid if __2nd_parameter_is_str(getfixturedefs) else item | ||
|
||
|
||
def __2nd_parameter_is_str(getfixturedefs): | ||
global __GETFIXTUREDEFS_2ND_PAR_IS_STR | ||
if __GETFIXTUREDEFS_2ND_PAR_IS_STR is None: | ||
__GETFIXTUREDEFS_2ND_PAR_IS_STR =\ | ||
__get_2nd_parameter_type(getfixturedefs) is str | ||
return __GETFIXTUREDEFS_2ND_PAR_IS_STR | ||
|
||
|
||
def __get_2nd_parameter_type(fn): | ||
return list( | ||
signature(fn).parameters.values() | ||
)[1].annotation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters