Skip to content

Commit 0dc6cb2

Browse files
committed
Move lru_cache wrapper to compat
Ref: pytest-dev#4227 (comment)
1 parent f466105 commit 0dc6cb2

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

src/_pytest/compat.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,3 +417,16 @@ class FuncargnamesCompatAttr(object):
417417
def funcargnames(self):
418418
""" alias attribute for ``fixturenames`` for pre-2.3 compatibility"""
419419
return self.fixturenames
420+
421+
422+
if six.PY2:
423+
424+
def lru_cache(*_, **__):
425+
def dec(fn):
426+
return fn
427+
428+
return dec
429+
430+
431+
else:
432+
from functools import lru_cache # noqa: F401

src/_pytest/config/__init__.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
""" command line options, ini-file and conftest.py processing. """
22
from __future__ import absolute_import, division, print_function
33
import argparse
4-
import functools
54
import inspect
65
import shlex
76
import types
@@ -20,6 +19,7 @@
2019
import _pytest.assertion
2120
from pluggy import PluginManager, HookimplMarker, HookspecMarker
2221
from _pytest._code import ExceptionInfo, filter_traceback
22+
from _pytest.compat import lru_cache
2323
from _pytest.compat import safe_str
2424
from .exceptions import UsageError, PrintHelp
2525
from .findpaths import determine_setup, exists
@@ -894,6 +894,7 @@ def _getini(self, name):
894894
assert type is None
895895
return value
896896

897+
@lru_cache(maxsize=None)
897898
def _getconftest_pathlist(self, name, path):
898899
try:
899900
mod, relroots = self.pluginmanager._rget_with_confmod(name, path)
@@ -908,10 +909,6 @@ def _getconftest_pathlist(self, name, path):
908909
values.append(relroot)
909910
return values
910911

911-
if six.PY3:
912-
# once we drop Python 2, please change this to use the normal decorator syntax (#4227)
913-
_getconftest_pathlist = functools.lru_cache(maxsize=None)(_getconftest_pathlist)
914-
915912
def _get_override_ini_value(self, name):
916913
value = None
917914
# override_ini is a list of "ini=value" options

0 commit comments

Comments
 (0)