def __init__(self, stdscr): self.stdscr = stdscr self.user_interface = UserInterface(self) self.all_entries = { 0: sort(read(PYTHON_HISTORY)), 1: sort(read(FAVORITES)), 2: remove_duplicates(read(PYTHON_HISTORY)) } self.to_restore = self.all_entries.copy() self.case_sensitivity = False self.view = 0 # 0 = sorted; 1 = favorites; 2 = history self.regex_match = False
def test_delete_python_history(command, fake_stdscr, fake_standard, fake_readline, tmp_path): shutil.copyfile("tests/history/fake_python_history", tmp_path / "history") app = App(fake_stdscr) app.delete_python_history(command) assert command not in read("tests/history/fake_python_history") shutil.move(tmp_path / "history", "tests/history/fake_python_history")
def test_add_or_rm_fav(shell, fixture, fake_stdscr): app = App(fake_stdscr) path = application.SHELLS[shell]["fav"] for value in (True, False): app.add_or_rm_fav("egg") favs = read(path) assert favs.__contains__("egg") == value
def __init__(self, stdscr: _CursesWindow): self.stdscr = stdscr self.user_interface = UserInterface(self) self.raw_history: List[str] = self.get_history() self.commands: Dict[View, List[str]] = { View.SORTED: sort(self.raw_history), View.FAVORITES: sort(read(SHELLS[SHELL]["fav"])), View.ALL: remove_duplicates(self.raw_history), } self.to_restore = self.commands.copy() self.regex_mode: bool = False self.case_sensitivity: bool = False self.view: View = View.SORTED self.search_string = ""
def test_get_history(shell, fixture, fake_stdscr): app = App(fake_stdscr) assert app.get_history() == read( f"tests/history/fake_{shell.value}_history")
def test_read_some(tmp_path): history = tmp_path / "spam" history.write_text("eggs") assert read(history) == ["eggs"]
def test_read_file_creation(tmp_path): assert read(tmp_path / "spam") == [""]
def test_read_none(): with pytest.raises(AssertionError): read(None)
def __init__(self): self.history = read("tests/history/fake_python_history")
def fake_get_ipython_history(): return read(application.SHELLS[Shell.IPYTHON]["hist"])
def get_history(self) -> List[str]: # pylint: disable=no-self-use if SHELL == Shell.IPYTHON: return get_ipython_history() return read(SHELLS[SHELL]["hist"])