Skip to content

Commit 7cf1814

Browse files
committed
tests: increase run time for pypy
1 parent 6dfdc3d commit 7cf1814

1 file changed

Lines changed: 20 additions & 6 deletions

File tree

‎tests/test_security_formatting.py‎

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,36 @@
1+
import platform
12
import time
23
from unittest import TestCase
34

45
from mistune import create_markdown
56

67

8+
IS_PYPY = platform.python_implementation() == "PyPy"
9+
10+
711
class TestFormattingSecurity(TestCase):
12+
def test_repeated_formatting_pairs_render_as_adjacent_spans(self):
13+
md = create_markdown(plugins=["strikethrough"])
14+
result = md("~~x~~" * 3)
15+
self.assertEqual(result.strip(), "<p><del>x</del><del>x</del><del>x</del></p>")
16+
817
def test_repeated_formatting_pairs_return_quickly(self):
918
cases = [
1019
("strikethrough", "~~x~~"),
1120
("mark", "==x=="),
1221
("insert", "^^x^^"),
1322
]
1423
for plugin, unit in cases:
15-
md = create_markdown(plugins=[plugin])
16-
text = unit * 3000
24+
with self.subTest(plugin=plugin):
25+
md = create_markdown(plugins=[plugin])
26+
md(unit)
27+
28+
repetitions = 500 if IS_PYPY else 3000
29+
deadline = 1.0 if IS_PYPY else 0.5
30+
text = unit * repetitions
1731

18-
start = time.monotonic()
19-
md(text)
20-
elapsed = time.monotonic() - start
32+
start = time.monotonic()
33+
md(text)
34+
elapsed = time.monotonic() - start
2135

22-
self.assertLess(elapsed, 0.5, plugin)
36+
self.assertLess(elapsed, deadline)

0 commit comments

Comments
 (0)