Skip to content

Commit d418648

Browse files
committed
added test (thanks @nicoddemus) and added links in Changelog
1 parent 1248f81 commit d418648

2 files changed

Lines changed: 21 additions & 1 deletion

File tree

CHANGELOG.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,15 @@
1010
Thanks `@nicoddemus`_ for the PR.
1111

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

1515
*
1616

1717

1818
.. _@cwitty: https://github.com/cwitty
19+
.. _@MSeifert04: https://github.com/MSeifert04
1920

21+
.. _#1965: https://github.com/pytest-dev/pytest/issues/1965
2022
.. _#1976: https://github.com/pytest-dev/pytest/issues/1976
2123
.. _#1998: https://github.com/pytest-dev/pytest/issues/1998
2224

testing/python/raises.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,3 +96,21 @@ def test_custom_raise_message(self):
9696
assert e.msg == message
9797
else:
9898
assert False, "Expected pytest.raises.Exception"
99+
100+
@pytest.mark.parametrize('method', ['function', 'with'])
101+
def test_raises_memoryleak(self, method):
102+
import weakref
103+
104+
class T:
105+
def __call__(self):
106+
raise ValueError
107+
108+
t = T()
109+
if method == 'function':
110+
pytest.raises(ValueError, t)
111+
else:
112+
with pytest.raises(ValueError):
113+
t()
114+
115+
t = weakref.ref(t)
116+
assert t() is None

0 commit comments

Comments
 (0)