Skip to content

Move lru_cache wrapper to compat #4239

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 25, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/_pytest/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
7 changes: 2 additions & 5 deletions src/_pytest/config/__init__.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -20,6 +19,7 @@
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
Expand Down Expand Up @@ -894,6 +894,7 @@ def _getini(self, name):
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)
Expand All @@ -908,10 +909,6 @@ def _getconftest_pathlist(self, name, path):
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
Expand Down