summaryrefslogtreecommitdiff
path: root/tests/test_leak.py
diff options
context:
space:
mode:
authorDavid Lord <davidism@gmail.com>2018-05-02 14:54:35 -0700
committerDavid Lord <davidism@gmail.com>2018-05-02 14:54:35 -0700
commit4d4fa0dd1ae28599c1dde5658cb3dcd7b8f75c71 (patch)
tree0d70bb86caad5b08d7e10357bf11ec5c9ea33fdb /tests/test_leak.py
parent0e8bdc2cc40e13565a2510fa9639df25c1aba5e0 (diff)
downloadmarkupsafe-4d4fa0dd1ae28599c1dde5658cb3dcd7b8f75c71.tar.gz
stop using unittestpytest
Diffstat (limited to 'tests/test_leak.py')
-rw-r--r--tests/test_leak.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/test_leak.py b/tests/test_leak.py
new file mode 100644
index 0000000..964341a
--- /dev/null
+++ b/tests/test_leak.py
@@ -0,0 +1,29 @@
+# -*- coding: utf-8 -*-
+import gc
+import sys
+
+import pytest
+
+from markupsafe import escape
+
+
+@pytest.mark.skipif(
+ hasattr(escape, 'func_code'),
+ reason='only test memory leak with speedups'
+)
+def test_markup_leaks():
+ counts = set()
+
+ for count in range(20):
+ for item in range(1000):
+ escape("foo")
+ escape("<foo>")
+ escape(u"foo")
+ escape(u"<foo>")
+
+ if hasattr(sys, 'pypy_version_info'):
+ gc.collect()
+
+ counts.add(len(gc.get_objects()))
+
+ assert len(counts) == 1