about summary refs log tree commit diff stats
path: root/test
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2010-04-16 16:12:47 +0200
committerhut <hut@lavabit.com>2010-04-16 16:12:47 +0200
commit2c9557d5164b0e31b9f7c1a36c0ac8bf8f002944 (patch)
tree1b610d2c20caf8ce5adf9bd7ac19c1d599fa0593 /test
parentdd6527f254cdb072f5fb7053b166ee4593265193 (diff)
downloadranger-2c9557d5164b0e31b9f7c1a36c0ac8bf8f002944.tar.gz
keymap: moved simulate_press to where it belongs: tc_newkeys
Diffstat (limited to 'test')
-rw-r--r--test/tc_newkeys.py19
1 files changed, 14 insertions, 5 deletions
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):