summaryrefslogtreecommitdiff
path: root/_pytest/compat.py
diff options
context:
space:
mode:
authorRonny Pfannschmidt <opensource@ronnypfannschmidt.de>2017-09-06 08:24:00 +0200
committerGitHub <noreply@github.com>2017-09-06 08:24:00 +0200
commitad36407747da6b6efa85fa202031f9f2e45741e3 (patch)
treec5011de7faff6a63a39282d1dc50af1a61e2f6d2 /_pytest/compat.py
parent181bd60bf99021e3d8936ade5f92d408c53d3419 (diff)
parent1fc185b6405e63df37eb16bbbc62c0ed50d84f21 (diff)
downloadpytest-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.py10
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