def test_parse_keys_no_keyfile(self): """Parse keybindings without any existing keyfiles.""" keyfile = os.path.join(self.configdir, "nope_not_a_keyfile") # Catch the sys.exit(1) with self.assertRaises(SystemExit): parser.parse_keys(keyfiles=[keyfile], running_tests=True) # pylint:disable=no-member output = sys.stdout.getvalue().strip() self.assertIn("Keyfile not found", output)
def test_parse_keys_missing_section(self): """Parse a keyfile missing a section.""" keybindings = self.keybindings del keybindings["IMAGE"] keyfile = self.create_keyfile(keybindings) # Catch the sys.exit(1) with self.assertRaises(SystemExit): parser.parse_keys(keyfiles=[keyfile], running_tests=True) # pylint:disable=no-member output = sys.stdout.getvalue().strip() self.assertIn("Missing section", output)
def test_parse_keys_duplicate(self): """Parse keybindings with a duplicate keybinding.""" keybindings = self.keybindings keyfile = self.create_keyfile(keybindings) with open(keyfile, "a") as f: f.write("\na: scroll j") # Catch the sys.exit(1) with self.assertRaises(SystemExit): parser.parse_keys(keyfiles=[keyfile], running_tests=True) # pylint:disable=no-member output = sys.stdout.getvalue().strip() self.assertIn("Duplicate keybinding", output)
def test_parse_keys(self): """Parse a correct minimal keyfile.""" keyfile = self.create_keyfile(self.keybindings) parsed_bindings = parser.parse_keys(keyfiles=[keyfile], running_tests=True) # Checking one should be enough image = parsed_bindings["IMAGE"] self.assertEqual(self.keybindings["IMAGE"]["a"], image["a"])
def __init__(self, app, settings): """Create the necessary objects and settings. Args: vimiv: The main vimiv class to interact with. settings: Settings from configfiles to use. """ # Add events to vimiv self.app = app # Settings self.num_str = "" self.keys = parse_keys()
def __init__(self, app, settings): """Create the necessary objects and settings. Args: vimiv: The main vimiv class to interact with. settings: Settings from configfiles to use. """ # Add events to vimiv super().__init__(app) # Settings self.num_str = "" self.timer_id = 0 self.keys = parse_keys(running_tests=app.running_tests)
def test_parse_keys(self): """Check if the keybindings are parsed correctly.""" keybindings = parser.parse_keys() image_bindings = keybindings["IMAGE"] self.assertEqual(image_bindings["j"], "down")