diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index c852936b..a7ad601a 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -21,6 +21,7 @@ jobs: fail-fast: false matrix: include: + - {python: '3.13'} - {python: '3.12'} - {name: Windows, python: '3.12', os: windows-latest} - {name: Mac, python: '3.12', os: macos-latest} diff --git a/tests/test_leak.py b/tests/test_leak.py index 260f4844..b786e072 100644 --- a/tests/test_leak.py +++ b/tests/test_leak.py @@ -1,31 +1,25 @@ from __future__ import annotations import gc -import platform -import pytest - -from markupsafe import _escape_inner # type: ignore[attr-defined] from markupsafe import escape -@pytest.mark.skipif( - _escape_inner.__module__ == "markupsafe._native", - reason="only test memory leak with speedups", -) def test_markup_leaks() -> None: counts = set() + # Try to start with a "clean" count. Works for PyPy but not 3.13 JIT. + gc.collect() - for _i in range(20): - for _j in range(1000): + for _ in range(20): + for _ in range(1000): escape("foo") escape("") escape("foo") escape("") - if platform.python_implementation() == "PyPy": - gc.collect() - counts.add(len(gc.get_objects())) - assert len(counts) == 1 + # Some implementations, such as PyPy and Python 3.13 JIT, end up with 2 + # counts rather than one. Presumably this is internals stabilizing. A leak + # would presumably have a different count every loop. + assert len(counts) < 3 diff --git a/tox.ini b/tox.ini index 8fb07c26..e961b1a3 100644 --- a/tox.ini +++ b/tox.ini @@ -1,6 +1,6 @@ [tox] envlist = - py3{12,11,10,9,8} + py3{13,12,11,10,9,8} pypy310 style typing