Merge pull request #2249 from pfhayes/anydbmfix

Fix importing anydbm within pytest
This commit is contained in:
Bruno Oliveira 2017-03-01 14:41:31 -03:00 committed by GitHub
commit 5721d8aed1
3 changed files with 11 additions and 1 deletions

View File

@ -113,6 +113,7 @@ Nicolas Delaby
Oleg Pidsadnyi
Oliver Bestwalter
Omar Kohl
Patrick Hayes
Pieter Mulder
Piotr Banaszkiewicz
Punyashloka Biswal

View File

@ -1,6 +1,12 @@
3.0.7 (unreleased)
==================
* Fix issue in assertion rewriting breaking due to modules silently discarding
other modules when importing fails
Notably, importing the `anydbm` module is fixed. (`#2248`_).
Thanks `@pfhayes`_ for the PR.
* junitxml: Fix problematic case where system-out tag occured twice per testcase
element in the XML report. Thanks `@kkoukiou`_ for the PR.
@ -30,12 +36,14 @@
*
.. _@pfhayes: https://github.com/pfhayes
.. _@bluetech: https://github.com/bluetech
.. _@gst: https://github.com/gst
.. _@sirex: https://github.com/sirex
.. _@vidartf: https://github.com/vidartf
.. _@kkoukiou: https://github.com/KKoukiou
.. _#2248: https://github.com/pytest-dev/pytest/issues/2248
.. _#2137: https://github.com/pytest-dev/pytest/issues/2137
.. _#2160: https://github.com/pytest-dev/pytest/issues/2160
.. _#2231: https://github.com/pytest-dev/pytest/issues/2231

View File

@ -215,7 +215,8 @@ class AssertionRewritingHook(object):
mod.__loader__ = self
py.builtin.exec_(co, mod.__dict__)
except:
del sys.modules[name]
if name in sys.modules:
del sys.modules[name]
raise
return sys.modules[name]