diff --git a/_pytest/capture.py b/_pytest/capture.py index 164d5538b..1f4762b06 100644 --- a/_pytest/capture.py +++ b/_pytest/capture.py @@ -240,6 +240,8 @@ class EncodedFile(object): def __getattr__(self, name): if hasattr(self, "buffer"): return getattr(self.buffer, name) + else: + raise AttributeError("attribute buffer of %r not set" % self) class MultiCapture(object): diff --git a/_pytest/main.py b/_pytest/main.py index cbe2fabda..1be074243 100644 --- a/_pytest/main.py +++ b/_pytest/main.py @@ -159,6 +159,8 @@ class HookProxy: 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) def call_matching_hooks(**kwargs):