From 2c9557d5164b0e31b9f7c1a36c0ac8bf8f002944 Mon Sep 17 00:00:00 2001 From: hut Date: Fri, 16 Apr 2010 16:12:47 +0200 Subject: keymap: moved simulate_press to where it belongs: tc_newkeys --- test/tc_newkeys.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'test') diff --git a/test/tc_newkeys.py b/test/tc_newkeys.py index 06345450..9bfb43b0 100644 --- a/test/tc_newkeys.py +++ b/test/tc_newkeys.py @@ -23,12 +23,21 @@ from ranger.ext.keybinding_parser import parse_keybinding import sys +def simulate_press(self, string): + for char in parse_keybinding(string): + self.add(char) + if self.done: + return self.command + if self.failure: + break + return self.command + class PressTestCase(TestCase): """Some useful methods for the actual test""" def _mkpress(self, keybuffer, _=0): def press(keys): keybuffer.clear() - match = keybuffer.simulate_press(keys) + match = simulate_press(keybuffer, keys) self.assertFalse(keybuffer.failure, "parsing keys '"+keys+"' did fail!") self.assertTrue(keybuffer.done, @@ -41,13 +50,13 @@ class PressTestCase(TestCase): def assertPressFails(self, kb, keys): kb.clear() - kb.simulate_press(keys) + simulate_press(kb, keys) self.assertTrue(kb.failure, "Keypress did not fail as expected") kb.clear() def assertPressIncomplete(self, kb, keys): kb.clear() - kb.simulate_press(keys) + simulate_press(kb, keys) self.assertFalse(kb.failure, "Keypress failed, expected incomplete") self.assertFalse(kb.done, "Keypress done which was unexpected") kb.clear() @@ -78,7 +87,7 @@ class Test(PressTestCase): self.assertEqual(2, press('ppj')) kb.clear() - match = kb.simulate_press('pp') + match = simulate_press(kb, 'pp') args = CommandArgs(0, 0, kb) self.assert_(match) self.assert_(match.function) @@ -414,7 +423,7 @@ class Test(PressTestCase): self.assertPressIncomplete(kb, 'xx') self.assertPressIncomplete(kb, 'x') if not sys.flags.optimize: - self.assertRaises(AssertionError, kb.simulate_press, 'xxx') + self.assertRaises(AssertionError, simulate_press, kb, 'xxx') kb.clear() def test_directions_as_functions(self): -- cgit 1.4.1-2-gfad0