Removed escape function int tests, added a constant for it

This commit is contained in:
Holger Rapp 2009-07-05 13:20:58 +02:00
parent 3e34086b8e
commit 58731e251d
2 changed files with 19 additions and 21 deletions

View File

@ -768,6 +768,9 @@ class SnippetManager(object):
return True return True
def cursor_moved(self): def cursor_moved(self):
debug("Cursor moved")
self._cursor.update_position() self._cursor.update_position()
if len(self._current_snippets) and (self._cursor.has_moved): if len(self._current_snippets) and (self._cursor.has_moved):

37
test.py
View File

@ -7,6 +7,14 @@ import tempfile
import unittest import unittest
import time import time
# Some constants for better reading
BS = '\x7f'
ESC = '\x1b'
ARR_L = '\x1bOD'
ARR_R = '\x1bOC'
ARR_U = '\x1bOA'
ARR_D = '\x1bOB'
def send(s,session): def send(s,session):
os.system("screen -x %s -X stuff '%s'" % (session,s)) os.system("screen -x %s -X stuff '%s'" % (session,s))
@ -33,11 +41,8 @@ class _VimTest(unittest.TestCase):
'\n\n' + self.text_after '\n\n' + self.text_after
self.assertEqual(self.output, wanted) self.assertEqual(self.output, wanted)
def escape(self):
self.type("\x1b")
def setUp(self): def setUp(self):
self.escape() self.send(ESC)
self.send(":py PySnipSnippets.reset()\n") self.send(":py PySnipSnippets.reset()\n")
@ -66,8 +71,7 @@ EOF
self.send('\n\n' + self.text_after) self.send('\n\n' + self.text_after)
# Go to the middle of the buffer # Go to the middle of the buffer
self.escape() self.send(ESC + "ggjji")
self.send("ggjji")
# Execute the command # Execute the command
self.cmd() self.cmd()
@ -77,8 +81,7 @@ EOF
os.close(handle) os.close(handle)
os.unlink(fn) os.unlink(fn)
self.escape() self.send(ESC + ":w! %s\n" % fn)
self.send(":w! %s\n" % fn)
# Read the output, chop the trailing newline # Read the output, chop the trailing newline
tries = 50 tries = 50
@ -124,26 +127,20 @@ class DoNotExpandAfterSpace_ExceptCorrectResult(_SimpleExpands):
class ExpandInTheMiddleOfLine_ExceptCorrectResult(_SimpleExpands): class ExpandInTheMiddleOfLine_ExceptCorrectResult(_SimpleExpands):
wanted = "Wie Hallo Welt! gehts?" wanted = "Wie Hallo Welt! gehts?"
def cmd(self): def cmd(self):
self.type("Wie hallo gehts?") self.type("Wie hallo gehts?" + ESC + "bhi\t")
self.escape()
self.type("bhi\t")
def runTest(self): self.check_output() def runTest(self): self.check_output()
class MultilineExpand_ExceptCorrectResult(_VimTest): class MultilineExpand_ExceptCorrectResult(_VimTest):
wanted = "Wie Hallo Welt!\nUnd Wie gehts? gehts?" wanted = "Wie Hallo Welt!\nUnd Wie gehts? gehts?"
snippets = ("hallo", "Hallo Welt!\nUnd Wie gehts?") snippets = ("hallo", "Hallo Welt!\nUnd Wie gehts?")
def cmd(self): def cmd(self):
self.type("Wie hallo gehts?") self.type("Wie hallo gehts?" + ESC + "bhi\t")
self.escape()
self.type("bhi\t")
def runTest(self): self.check_output() def runTest(self): self.check_output()
class MultilineExpandTestTyping_ExceptCorrectResult(_VimTest): class MultilineExpandTestTyping_ExceptCorrectResult(_VimTest):
snippets = ("hallo", "Hallo Welt!\nUnd Wie gehts?") snippets = ("hallo", "Hallo Welt!\nUnd Wie gehts?")
wanted = "Wie Hallo Welt!\nUnd Wie gehts?Huiui! gehts?" wanted = "Wie Hallo Welt!\nUnd Wie gehts?Huiui! gehts?"
def cmd(self): def cmd(self):
self.type("Wie hallo gehts?") self.type("Wie hallo gehts?" + ESC + "bhi\tHuiui!")
self.escape()
self.type("bhi\tHuiui!")
def runTest(self): self.check_output() def runTest(self): self.check_output()
############ ############
@ -225,10 +222,8 @@ class TabStopTestMultilineExpand_ExceptCorrectResult(_VimTest):
wanted = "test hallo one more\nnice world work\n" \ wanted = "test hallo one more\nnice world work\n" \
"test try\nSeem to work World" "test try\nSeem to work World"
def cmd(self): def cmd(self):
self.type("test hallo World") self.type("test hallo World" + ESC + "02f i\t"
self.escape() "world\ttry\ttest\tone more\t\t")
self.type("02f i\t")
self.type("world\ttry\ttest\tone more\t\t")
def runTest(self): self.check_output() def runTest(self): self.check_output()
# # TODO: pasting with <C-R> while mirroring # # TODO: pasting with <C-R> while mirroring