summaryrefslogtreecommitdiffstats
path: root/tests/test_leak.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_leak.py')
-rw-r--r--tests/test_leak.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/test_leak.py b/tests/test_leak.py
new file mode 100644
index 0000000..55b10b9
--- /dev/null
+++ b/tests/test_leak.py
@@ -0,0 +1,28 @@
+import gc
+import platform
+
+import pytest
+
+from markupsafe import escape
+
+
+@pytest.mark.skipif(
+ escape.__module__ == "markupsafe._native",
+ reason="only test memory leak with speedups",
+)
+def test_markup_leaks():
+ counts = set()
+
+ for _i in range(20):
+ for _j in range(1000):
+ escape("foo")
+ escape("<foo>")
+ escape("foo")
+ escape("<foo>")
+
+ if platform.python_implementation() == "PyPy":
+ gc.collect()
+
+ counts.add(len(gc.get_objects()))
+
+ assert len(counts) == 1