From 65be1231b12367de3ff14b5718125d12a54b26b1 Mon Sep 17 00:00:00 2001 From: Lev Maximov Date: Sun, 18 Sep 2016 22:34:48 +0700 Subject: [PATCH] AttributeError chaining bug #1944 fix --- _pytest/python.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/_pytest/python.py b/_pytest/python.py index 33e7cff66..f26c128ca 100644 --- a/_pytest/python.py +++ b/_pytest/python.py @@ -205,11 +205,10 @@ class PyobjContext(object): class PyobjMixin(PyobjContext): def obj(): def fget(self): - try: - return self._obj - except AttributeError: + obj = getattr(self, '_obj', None) + if obj is None: self._obj = obj = self._getobj() - return obj + return obj def fset(self, value): self._obj = value return property(fget, fset, None, "underlying python object")