MCPcopy
hub / github.com/hylang/hy / test_history_custom_location

Function test_history_custom_location

tests/test_completer.py:15–35  ·  view source on GitHub ↗
(tmp_path)

Source from the content-addressed store, hash-verified

13 not hy.completer.readline, reason="Module 'readline' is not available."
14)
15def test_history_custom_location(tmp_path):
16 import readline
17
18 expected_entry = '(print "Hy, custom history file!")'
19
20 history_location = tmp_path / ".hy-custom-history"
21 os.environ["HY_HISTORY"] = str(history_location)
22
23 with hy.completer.completion():
24 readline.clear_history()
25 readline.add_history(expected_entry)
26
27 actual_entry = history_location.read_text()
28
29 # yes, this is recommended way to check GNU readline vs libedit
30 # see https://docs.python.org/3.11/library/readline.html
31 if "libedit" in readline.__doc__:
32 # libedit saves spaces as octal escapes, so convert them back
33 actual_entry = actual_entry.replace("\\040", " ")
34
35 assert expected_entry in actual_entry
36
37
38def test_completion():

Callers

nothing calls this directly

Calls 1

replaceMethod · 0.45

Tested by

no test coverage detected