Skip to content

Commit 8d0c8dd

Browse files
charliegilletclaude
authored andcommitted
test(nodes): remove wall-clock thresholds from template engine tests
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent e88389d commit 8d0c8dd

1 file changed

Lines changed: 6 additions & 8 deletions

File tree

nodes/test/test_prompt_template_engine.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -337,16 +337,14 @@ def test_html_entity_in_template_is_literal(self):
337337
# ===========================================================================
338338
class TestSafety:
339339
def test_large_literal_input_runs_quickly(self):
340-
# ~50KB of plain text with no placeholders — tokenizer regex must not
341-
# blow up (ReDoS guard). Timing check is intentionally loose.
342-
import time
343-
340+
# ~100KB with one placeholder: verifies the tokenizer regex handles
341+
# large literal runs correctly and does not catastrophically backtrack
342+
# (ReDoS guard). A regex blow-up would manifest as a multi-minute hang
343+
# that pytest would terminate — no wall-clock threshold is needed here,
344+
# and asserting one only introduces CI flakiness on slow/busy runners.
344345
template = 'x' * 50_000 + '{{v}}' + 'y' * 50_000
345-
start = time.perf_counter()
346346
out = render(template, {'v': 'MID'})
347-
elapsed = time.perf_counter() - start
348-
assert 'MID' in out
349-
assert elapsed < 2.0 # generous upper bound
347+
assert out == ('x' * 50_000 + 'MID' + 'y' * 50_000)
350348

351349
def test_many_placeholders(self):
352350
tpl = ''.join(f'{{{{v{i}}}}}' for i in range(500))

0 commit comments

Comments
 (0)