diff --git a/countess/plugins/hgvs_parser.py b/countess/plugins/hgvs_parser.py index a5b4b4f..29ccf7e 100644 --- a/countess/plugins/hgvs_parser.py +++ b/countess/plugins/hgvs_parser.py @@ -39,18 +39,17 @@ def process_dict(self, data: dict): output["prefix"] = m.group(2) value = m.group(3) - if value == "=": - variations = [] - else: + variations: list[str] = [] + if value != "=": if value.startswith("[") and value.endswith("]"): value = value[1:-1] variations = value.split(";") - for n, g in enumerate(guides, 1): - output[f"guide_{n}"] = g in variations + for n, g in enumerate(guides, 1): + output[f"guide_{n}"] = g in variations - max_variations = int(self.max_var) - variations = [v for v in variations if v not in guides] + max_variations = int(self.max_var) + variations = [v for v in variations if v not in guides] output_vars: list[Optional[str]] = [None] * max_variations output_locs: list[Optional[str]] = [None] * max_variations diff --git a/tests/gui/test_actions.py b/tests/gui/test_actions.py index 5bc7f21..7d19241 100644 --- a/tests/gui/test_actions.py +++ b/tests/gui/test_actions.py @@ -5,26 +5,28 @@ import pytest -from countess.gui.main import MainWindow, make_root, PluginChooserFrame from countess.gui.config import PluginConfigurator +from countess.gui.main import MainWindow, PluginChooserFrame, make_root from countess.gui.tabular import TabularDataFrame from countess.plugins.csv import LoadCsvPlugin -def _find_buttons(frame: tk.Frame, label: str) -> Iterable[tk.Button]: +def _find_buttons(frame: tk.Frame, label: str) -> Iterable[tk.Button]: for w in frame.winfo_children(): if isinstance(w, tk.Button): - if w['text'] == label: + if w["text"] == label: yield w elif isinstance(w, (tk.Frame, tk.LabelFrame)): yield from _find_buttons(w, label) + def _find_button(frame: tk.Frame, label: str) -> Optional[tk.Button]: try: return next(iter(_find_buttons(frame, label))) except StopIteration: return None + @pytest.mark.gui def test_open_new(): root = make_root() @@ -33,7 +35,7 @@ def test_open_new(): assert isinstance(mw.config_wrapper.config_subframe, PluginChooserFrame) - button = _find_button(mw.config_wrapper.config_subframe, 'CSV Load') + button = _find_button(mw.config_wrapper.config_subframe, "CSV Load") button.invoke() root.update() @@ -41,7 +43,7 @@ def test_open_new(): plugin = mw.config_wrapper.configurator.plugin assert isinstance(plugin, LoadCsvPlugin) - with patch('tkinter.filedialog.askopenfilenames', return_value=['tests/input1.csv']): + with patch("tkinter.filedialog.askopenfilenames", return_value=["tests/input1.csv"]): button = _find_button(mw.config_wrapper.config_subframe, "") button.invoke() root.update() diff --git a/tests/test_cmd.py b/tests/test_cmd.py index 8f01fd9..18cb011 100644 --- a/tests/test_cmd.py +++ b/tests/test_cmd.py @@ -1,4 +1,5 @@ import csv +import time from unittest.mock import patch import pytest @@ -16,7 +17,7 @@ @pytest.mark.slow def test_command_invocation(): run(["countess_cmd", "tests/simple.ini"]) - + time.sleep(0.5) with open("tests/output.csv", "r", encoding="utf-8") as fh: output = fh.read() assert output == expected_output