diff options
author | Ronny Pfannschmidt <opensource@ronnypfannschmidt.de> | 2017-09-06 08:24:00 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-06 08:24:00 +0200 |
commit | ad36407747da6b6efa85fa202031f9f2e45741e3 (patch) | |
tree | c5011de7faff6a63a39282d1dc50af1a61e2f6d2 /_pytest/compat.py | |
parent | 181bd60bf99021e3d8936ade5f92d408c53d3419 (diff) | |
parent | 1fc185b6405e63df37eb16bbbc62c0ed50d84f21 (diff) | |
download | pytest-ad36407747da6b6efa85fa202031f9f2e45741e3.tar.gz |
Merge pull request #2700 from nicoddemus/staticmethods-fixtures
Allow tests declared as @staticmethod to use fixtures
Diffstat (limited to '_pytest/compat.py')
-rw-r--r-- | _pytest/compat.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/_pytest/compat.py b/_pytest/compat.py index 54271ce4f..255f69ce0 100644 --- a/_pytest/compat.py +++ b/_pytest/compat.py @@ -83,7 +83,15 @@ def num_mock_patch_args(function): return len(patchings) -def getfuncargnames(function, startindex=None): +def getfuncargnames(function, startindex=None, cls=None): + """ + @RonnyPfannschmidt: This function should be refactored when we revisit fixtures. The + fixture mechanism should ask the node for the fixture names, and not try to obtain + directly from the function object well after collection has occurred. + """ + if startindex is None and cls is not None: + is_staticmethod = isinstance(cls.__dict__.get(function.__name__, None), staticmethod) + startindex = 0 if is_staticmethod else 1 # XXX merge with main.py's varnames # assert not isclass(function) realfunction = function |