summaryrefslogtreecommitdiff
path: root/testing
diff options
context:
space:
mode:
authorMichael Seifert <michaelseifert04@yahoo.de>2016-10-18 01:22:53 +0200
committerBruno Oliveira <nicoddemus@gmail.com>2016-11-08 22:13:02 -0200
commit552c7d4286f582255752730d2c512d0aff4a44c4 (patch)
treed2ef05bf1dce38b08e98046a4fdee5731d71cbaa /testing
parent1e5b21cd6180009939130f6169c936427d0d4572 (diff)
downloadpytest-552c7d4286f582255752730d2c512d0aff4a44c4.tar.gz
added test (thanks @nicoddemus) and added links in Changelog
Diffstat (limited to 'testing')
-rw-r--r--testing/python/raises.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/testing/python/raises.py b/testing/python/raises.py
index 59fd622fd..80c3df2ab 100644
--- a/testing/python/raises.py
+++ b/testing/python/raises.py
@@ -96,3 +96,21 @@ class TestRaises:
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