Use py3k compatible .__getattr__() code

From the python-dev thread it seemed like using
object.__getattribute__(self, 'name') is the cleanest way of
implementing a class wich uses .__getattr__() and should be
pickelable.  That only works on new-style classes so this also turns
HookProxy into a new-style class on py2.

This also re-writes the test to not use cPickle so it runs on py3k.
This commit is contained in:
Floris Bruynooghe
2014-09-05 23:55:14 +01:00
parent d1bde69c1e
commit 7d9d502a01
4 changed files with 11 additions and 15 deletions
+3 -4
View File
@@ -153,15 +153,14 @@ def pytest_ignore_collect(path, config):
ignore_paths.extend([py.path.local(x) for x in excludeopt])
return path in ignore_paths
class HookProxy:
class HookProxy(object):
def __init__(self, fspath, config):
self.fspath = fspath
self.config = config
def __getattr__(self, name):
if not hasattr(self, "config"):
raise AttributeError("attribute config of %r not set" % self)
hookmethod = getattr(self.config.hook, name)
config = object.__getattribute__(self, "config")
hookmethod = getattr(config.hook, name)
def call_matching_hooks(**kwargs):
plugins = self.config._getmatchingplugins(self.fspath)