Merged in uweschmitt/pytest/default (pull request #194)

This commit is contained in:
Floris Bruynooghe 2014-09-05 23:57:18 +01:00
commit a8dfe34bfb
4 changed files with 15 additions and 4 deletions

View File

@ -57,7 +57,7 @@ class View(object):
def __getattr__(self, attr):
# attributes not found in the normal hierarchy rooted on View
# are looked up in the object's real class
return getattr(self.__obj__, attr)
return getattr(object.__getattribute__(self, '__obj__'), attr)
def __viewkey__(self):
return self.__obj__.__class__

View File

@ -238,7 +238,7 @@ class EncodedFile(object):
self.write(data)
def __getattr__(self, name):
return getattr(self.buffer, name)
return getattr(object.__getattribute__(self, "buffer"), name)
class MultiCapture(object):

View File

@ -153,13 +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):
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)

View File

@ -1,6 +1,7 @@
# note: py.io capture tests where copied from
# pylib 1.4.20.dev2 (rev 13d9af95547e)
from __future__ import with_statement
import pickle
import os
import sys
import py
@ -1022,3 +1023,12 @@ def test_error_attribute_issue555(testdir):
""")
reprec = testdir.inline_run()
reprec.assertoutcome(passed=1)
def test_pickling_and_unpickling_enocded_file():
# See https://bitbucket.org/hpk42/pytest/pull-request/194
# pickle.loads() raises infinite recursion if
# EncodedFile.__getattr__ is not implemented properly
ef = capture.EncodedFile(None, None)
ef_as_str = pickle.dumps(ef)
pickle.loads(ef_as_str)