Merge pull request #4239 from blueyed/lru_cache

Move lru_cache wrapper to compat
This commit is contained in:
Daniel Hahler 2018-10-25 20:09:01 +02:00 committed by GitHub
commit 6dc575f5ee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 5 deletions

View File

@ -417,3 +417,16 @@ class FuncargnamesCompatAttr(object):
def funcargnames(self):
""" alias attribute for ``fixturenames`` for pre-2.3 compatibility"""
return self.fixturenames
if six.PY2:
def lru_cache(*_, **__):
def dec(fn):
return fn
return dec
else:
from functools import lru_cache # noqa: F401

View File

@ -1,7 +1,6 @@
""" command line options, ini-file and conftest.py processing. """
from __future__ import absolute_import, division, print_function
import argparse
import functools
import inspect
import shlex
import types
@ -20,6 +19,7 @@ import _pytest.hookspec # the extension point definitions
import _pytest.assertion
from pluggy import PluginManager, HookimplMarker, HookspecMarker
from _pytest._code import ExceptionInfo, filter_traceback
from _pytest.compat import lru_cache
from _pytest.compat import safe_str
from .exceptions import UsageError, PrintHelp
from .findpaths import determine_setup, exists
@ -894,6 +894,7 @@ class Config(object):
assert type is None
return value
@lru_cache(maxsize=None)
def _getconftest_pathlist(self, name, path):
try:
mod, relroots = self.pluginmanager._rget_with_confmod(name, path)
@ -908,10 +909,6 @@ class Config(object):
values.append(relroot)
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):
value = None
# override_ini is a list of "ini=value" options