Move lru_cache wrapper to compat
Ref: https://github.com/pytest-dev/pytest/pull/4227#discussion_r228060373
This commit is contained in:
parent
f466105d66
commit
0dc6cb298e
|
@ -417,3 +417,16 @@ class FuncargnamesCompatAttr(object):
|
||||||
def funcargnames(self):
|
def funcargnames(self):
|
||||||
""" alias attribute for ``fixturenames`` for pre-2.3 compatibility"""
|
""" alias attribute for ``fixturenames`` for pre-2.3 compatibility"""
|
||||||
return self.fixturenames
|
return self.fixturenames
|
||||||
|
|
||||||
|
|
||||||
|
if six.PY2:
|
||||||
|
|
||||||
|
def lru_cache(*_, **__):
|
||||||
|
def dec(fn):
|
||||||
|
return fn
|
||||||
|
|
||||||
|
return dec
|
||||||
|
|
||||||
|
|
||||||
|
else:
|
||||||
|
from functools import lru_cache # noqa: F401
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
""" command line options, ini-file and conftest.py processing. """
|
""" command line options, ini-file and conftest.py processing. """
|
||||||
from __future__ import absolute_import, division, print_function
|
from __future__ import absolute_import, division, print_function
|
||||||
import argparse
|
import argparse
|
||||||
import functools
|
|
||||||
import inspect
|
import inspect
|
||||||
import shlex
|
import shlex
|
||||||
import types
|
import types
|
||||||
|
@ -20,6 +19,7 @@ import _pytest.hookspec # the extension point definitions
|
||||||
import _pytest.assertion
|
import _pytest.assertion
|
||||||
from pluggy import PluginManager, HookimplMarker, HookspecMarker
|
from pluggy import PluginManager, HookimplMarker, HookspecMarker
|
||||||
from _pytest._code import ExceptionInfo, filter_traceback
|
from _pytest._code import ExceptionInfo, filter_traceback
|
||||||
|
from _pytest.compat import lru_cache
|
||||||
from _pytest.compat import safe_str
|
from _pytest.compat import safe_str
|
||||||
from .exceptions import UsageError, PrintHelp
|
from .exceptions import UsageError, PrintHelp
|
||||||
from .findpaths import determine_setup, exists
|
from .findpaths import determine_setup, exists
|
||||||
|
@ -894,6 +894,7 @@ class Config(object):
|
||||||
assert type is None
|
assert type is None
|
||||||
return value
|
return value
|
||||||
|
|
||||||
|
@lru_cache(maxsize=None)
|
||||||
def _getconftest_pathlist(self, name, path):
|
def _getconftest_pathlist(self, name, path):
|
||||||
try:
|
try:
|
||||||
mod, relroots = self.pluginmanager._rget_with_confmod(name, path)
|
mod, relroots = self.pluginmanager._rget_with_confmod(name, path)
|
||||||
|
@ -908,10 +909,6 @@ class Config(object):
|
||||||
values.append(relroot)
|
values.append(relroot)
|
||||||
return values
|
return values
|
||||||
|
|
||||||
if six.PY3:
|
|
||||||
# once we drop Python 2, please change this to use the normal decorator syntax (#4227)
|
|
||||||
_getconftest_pathlist = functools.lru_cache(maxsize=None)(_getconftest_pathlist)
|
|
||||||
|
|
||||||
def _get_override_ini_value(self, name):
|
def _get_override_ini_value(self, name):
|
||||||
value = None
|
value = None
|
||||||
# override_ini is a list of "ini=value" options
|
# override_ini is a list of "ini=value" options
|
||||||
|
|
Loading…
Reference in New Issue