Import AITURK IDE 1.0.0-beta.1 from Hermes 63279301; preserve MIT license
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
"""Tests for shared user prompt input sanitization."""
|
||||
|
||||
from hermes_cli.input_sanitize import (
|
||||
collapse_repeated_input_artifacts,
|
||||
sanitize_user_prompt_text,
|
||||
strip_leaked_bracketed_paste_wrappers,
|
||||
)
|
||||
|
||||
|
||||
class TestStripLeakedBracketedPasteWrappers:
|
||||
def test_plain_text_unchanged(self):
|
||||
assert strip_leaked_bracketed_paste_wrappers("hello world") == "hello world"
|
||||
|
||||
|
||||
|
||||
def test_does_not_strip_non_wrapper_bracket_forms_in_normal_text(self):
|
||||
text = "literal[200~tag and literal[201~tag should stay"
|
||||
assert strip_leaked_bracketed_paste_wrappers(text) == text
|
||||
|
||||
|
||||
class TestCollapseRepeatedInputArtifacts:
|
||||
def test_issue_62557_corruption_tail(self):
|
||||
prefix = "需要时随时叫我。"
|
||||
tail = "[e~[[e" + "~[[e" * 20
|
||||
assert collapse_repeated_input_artifacts(prefix + tail) == prefix
|
||||
|
||||
|
||||
def test_trailing_punctuation_preserved(self):
|
||||
assert collapse_repeated_input_artifacts("wait....") == "wait...."
|
||||
|
||||
|
||||
class TestSanitizeUserPromptText:
|
||||
def test_combines_wrapper_strip_and_tail_collapse(self):
|
||||
prefix = "hello["
|
||||
corrupted = prefix + "~[[e" * 8
|
||||
assert sanitize_user_prompt_text(corrupted) == "hello"
|
||||
Reference in New Issue
Block a user