Skip to content

Commit

Permalink
added test (thanks @nicoddemus) and added links in Changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
MSeifert04 authored and nicoddemus committed Nov 9, 2016
1 parent 1e5b21c commit 552c7d4
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
10 changes: 6 additions & 4 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
Thanks `@nicoddemus`_ for the PR.

* Fixed memory leak in the RaisesContext (pytest.raises) (`#1965`_).
Thanks `@MSeifert04`_ for the report the PR.
Thanks `@MSeifert04`_ for the report and the PR.

* Fixed false-positives warnings from assertion rewrite hook for modules that were rewritten but
were later marked explicitly by ``pytest.register_assert_rewrite``
Expand All @@ -39,12 +39,14 @@

.. _@adborden: https://github.com/adborden
.. _@cwitty: https://github.com/cwitty
.. _@okulynyak: https://github.com/okulynyak
.. _@matclab: https://github.com/matclab
.. _@gdyuldin: https://github.com/gdyuldin
.. _@d_b_w: https://github.com/d_b_w
.. _@gdyuldin: https://github.com/gdyuldin
.. _@matclab: https://github.com/matclab
.. _@MSeifert04: https://github.com/MSeifert04
.. _@okulynyak: https://github.com/okulynyak

.. _#442: https://github.com/pytest-dev/pytest/issues/442
.. _#1965: https://github.com/pytest-dev/pytest/issues/1965
.. _#1976: https://github.com/pytest-dev/pytest/issues/1976
.. _#1984: https://github.com/pytest-dev/pytest/issues/1984
.. _#1998: https://github.com/pytest-dev/pytest/issues/1998
Expand Down
18 changes: 18 additions & 0 deletions testing/python/raises.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,21 @@ def test_custom_raise_message(self):
assert e.msg == message
else:
assert False, "Expected pytest.raises.Exception"

@pytest.mark.parametrize('method', ['function', 'with'])
def test_raises_memoryleak(self, method):
import weakref

class T:
def __call__(self):
raise ValueError

t = T()
if method == 'function':
pytest.raises(ValueError, t)
else:
with pytest.raises(ValueError):
t()

t = weakref.ref(t)
assert t() is None

0 comments on commit 552c7d4

Please sign in to comment.