remove memocollect anmd memoized_call

This commit is contained in:
Ronny Pfannschmidt 2016-08-27 13:04:00 +02:00
parent e572c16d3f
commit e1674f60e7
3 changed files with 10 additions and 7 deletions

View File

@ -455,10 +455,6 @@ class Collector(Node):
return str(exc.args[0]) return str(exc.args[0])
return self._repr_failure_py(excinfo, style="short") return self._repr_failure_py(excinfo, style="short")
def _memocollect(self):
""" internal helper method to cache results of calling collect(). """
return self._memoizedcall('_collected', lambda: list(self.collect()))
def _prunetraceback(self, excinfo): def _prunetraceback(self, excinfo):
if hasattr(self, 'fspath'): if hasattr(self, 'fspath'):
traceback = excinfo.traceback traceback = excinfo.traceback

View File

@ -10,6 +10,8 @@ import time
import traceback import traceback
from fnmatch import fnmatch from fnmatch import fnmatch
from weakref import WeakKeyDictionary
from py.builtin import print_ from py.builtin import print_
from _pytest._code import Source from _pytest._code import Source
@ -401,6 +403,7 @@ class Testdir:
def __init__(self, request, tmpdir_factory): def __init__(self, request, tmpdir_factory):
self.request = request self.request = request
self._mod_collections = WeakKeyDictionary()
# XXX remove duplication with tmpdir plugin # XXX remove duplication with tmpdir plugin
basetmp = tmpdir_factory.ensuretemp("testdir") basetmp = tmpdir_factory.ensuretemp("testdir")
name = request.function.__name__ name = request.function.__name__
@ -856,6 +859,7 @@ class Testdir:
self.makepyfile(__init__ = "#") self.makepyfile(__init__ = "#")
self.config = config = self.parseconfigure(path, *configargs) self.config = config = self.parseconfigure(path, *configargs)
node = self.getnode(config, path) node = self.getnode(config, path)
return node return node
def collect_by_name(self, modcol, name): def collect_by_name(self, modcol, name):
@ -870,7 +874,9 @@ class Testdir:
:param name: The name of the node to return. :param name: The name of the node to return.
""" """
for colitem in modcol._memocollect(): if modcol not in self._mod_collections:
self._mod_collections[modcol] = list(modcol.collect())
for colitem in self._mod_collections[modcol]:
if colitem.name == name: if colitem.name == name:
return colitem return colitem

View File

@ -330,7 +330,9 @@ class TeardownErrorReport(BaseReport):
self.__dict__.update(extra) self.__dict__.update(extra)
def pytest_make_collect_report(collector): def pytest_make_collect_report(collector):
call = CallInfo(collector._memocollect, "memocollect") call = CallInfo(
lambda: list(collector.collect()),
'collect')
longrepr = None longrepr = None
if not call.excinfo: if not call.excinfo:
outcome = "passed" outcome = "passed"
@ -568,4 +570,3 @@ def importorskip(modname, minversion=None):
raise Skipped("module %r has __version__ %r, required is: %r" %( raise Skipped("module %r has __version__ %r, required is: %r" %(
modname, verattr, minversion), allow_module_level=True) modname, verattr, minversion), allow_module_level=True)
return mod return mod