MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / MockCursesUI

Class MockCursesUI

tensorflow/python/debug/cli/curses_ui_test.py:48–232  ·  view source on GitHub ↗

Mock subclass of CursesUI that bypasses actual terminal manipulations.

Source from the content-addressed store, hash-verified

46
47
48class MockCursesUI(curses_ui.CursesUI):
49 """Mock subclass of CursesUI that bypasses actual terminal manipulations."""
50
51 def __init__(self,
52 height,
53 width,
54 command_sequence=None):
55 self._height = height
56 self._width = width
57
58 self._command_sequence = command_sequence
59 self._command_counter = 0
60
61 # The mock class has no actual textbox. So use this variable to keep
62 # track of what's entered in the textbox on creation.
63 self._curr_existing_command = ""
64
65 # Observers for test.
66 # Observers of screen output.
67 self.unwrapped_outputs = []
68 self.wrapped_outputs = []
69 self.scroll_messages = []
70 self.output_array_pointer_indices = []
71
72 self.output_pad_rows = []
73
74 # Observers of command textbox.
75 self.existing_commands = []
76
77 # Observer for tab-completion candidates.
78 self.candidates_lists = []
79
80 # Observer for the main menu.
81 self.main_menu_list = []
82
83 # Observer for toast messages.
84 self.toasts = []
85
86 curses_ui.CursesUI.__init__(
87 self,
88 config=cli_config.CLIConfig(
89 config_file_path=os.path.join(tempfile.mkdtemp(), ".tfdbg_config")))
90
91 # Override the default path to the command history file to avoid test
92 # concurrency issues.
93 self._command_history_store = debugger_cli_common.CommandHistory(
94 history_file_path=tempfile.mktemp())
95
96 # Below, override the _screen_ prefixed member methods that interact with the
97 # actual terminal, so that the mock can run in a terminal-less environment.
98
99 # TODO(cais): Search for a way to have a mock terminal object that behaves
100 # like the actual terminal, so that we can test the terminal interaction
101 # parts of the CursesUI class.
102
103 def _screen_init(self):
104 pass
105

Calls

no outgoing calls