Merge pull request #1945 from axil/master
AttributeError chaining bug #1944 fix
This commit is contained in:
commit
7660a19d0a
1
AUTHORS
1
AUTHORS
|
@ -78,6 +78,7 @@ Kale Kundert
|
||||||
Katarzyna Jachim
|
Katarzyna Jachim
|
||||||
Kevin Cox
|
Kevin Cox
|
||||||
Lee Kamentsky
|
Lee Kamentsky
|
||||||
|
Lev Maximov
|
||||||
Lukas Bednar
|
Lukas Bednar
|
||||||
Maciek Fijalkowski
|
Maciek Fijalkowski
|
||||||
Maho
|
Maho
|
||||||
|
|
|
@ -12,14 +12,20 @@
|
||||||
* Fix pkg_resources import error in Jython projects (`#1853`).
|
* Fix pkg_resources import error in Jython projects (`#1853`).
|
||||||
Thanks `@raquel-ucl`_ for the PR.
|
Thanks `@raquel-ucl`_ for the PR.
|
||||||
|
|
||||||
|
* Got rid of ``AttributeError: 'Module' object has no attribute '_obj'`` exception
|
||||||
|
in Python 3 (`#1944`_).
|
||||||
|
Thanks `@axil`_ for the PR.
|
||||||
|
|
||||||
*
|
*
|
||||||
|
|
||||||
|
|
||||||
.. _@philpep: https://github.com/philpep
|
.. _@philpep: https://github.com/philpep
|
||||||
.. _@raquel-ucl: https://github.com/raquel-ucl
|
.. _@raquel-ucl: https://github.com/raquel-ucl
|
||||||
|
.. _@axil: https://github.com/axil
|
||||||
|
|
||||||
.. _#1905: https://github.com/pytest-dev/pytest/issues/1905
|
.. _#1905: https://github.com/pytest-dev/pytest/issues/1905
|
||||||
.. _#1934: https://github.com/pytest-dev/pytest/issues/1934
|
.. _#1934: https://github.com/pytest-dev/pytest/issues/1934
|
||||||
|
.. _#1944: https://github.com/pytest-dev/pytest/issues/1944
|
||||||
|
|
||||||
|
|
||||||
3.0.2
|
3.0.2
|
||||||
|
|
|
@ -205,11 +205,10 @@ class PyobjContext(object):
|
||||||
class PyobjMixin(PyobjContext):
|
class PyobjMixin(PyobjContext):
|
||||||
def obj():
|
def obj():
|
||||||
def fget(self):
|
def fget(self):
|
||||||
try:
|
obj = getattr(self, '_obj', None)
|
||||||
return self._obj
|
if obj is None:
|
||||||
except AttributeError:
|
|
||||||
self._obj = obj = self._getobj()
|
self._obj = obj = self._getobj()
|
||||||
return obj
|
return obj
|
||||||
def fset(self, value):
|
def fset(self, value):
|
||||||
self._obj = value
|
self._obj = value
|
||||||
return property(fget, fset, None, "underlying python object")
|
return property(fget, fset, None, "underlying python object")
|
||||||
|
|
|
@ -864,3 +864,15 @@ def test_assert_with_unicode(monkeypatch, testdir):
|
||||||
""")
|
""")
|
||||||
result = testdir.runpytest()
|
result = testdir.runpytest()
|
||||||
result.stdout.fnmatch_lines(['*AssertionError*'])
|
result.stdout.fnmatch_lines(['*AssertionError*'])
|
||||||
|
|
||||||
|
def test_issue_1944(testdir):
|
||||||
|
testdir.makepyfile("""
|
||||||
|
def f():
|
||||||
|
return
|
||||||
|
|
||||||
|
assert f() == 10
|
||||||
|
""")
|
||||||
|
result = testdir.runpytest()
|
||||||
|
result.stdout.fnmatch_lines(["*1 error*"])
|
||||||
|
assert "AttributeError: 'Module' object has no attribute '_obj'" not in result.stdout.str()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue