Skip to content

Commit

Permalink
test with python 3.13 (#446)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidism committed May 11, 2024
2 parents 52d35f5 + ceccb11 commit 53d7cb7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 15 deletions.
1 change: 1 addition & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
22 changes: 8 additions & 14 deletions tests/test_leak.py
Original file line number Diff line number Diff line change
@@ -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("<foo>")
escape("foo")
escape("<foo>")

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
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tox]
envlist =
py3{12,11,10,9,8}
py3{13,12,11,10,9,8}
pypy310
style
typing
Expand Down

0 comments on commit 53d7cb7

Please sign in to comment.