Move getting buffer data into interface class
Put the code that instructs vim to write its buffer to a temporary file and then reads that file into a python string into the VimInterface class. This will allow that to be done by code outside of tests.
This commit is contained in:
parent
fc22af0d1e
commit
2ab17b6cca
30
test.py
30
test.py
@ -74,6 +74,21 @@ class VimInterface:
|
||||
self.send(c)
|
||||
time.sleep(sleeptime)
|
||||
|
||||
def get_buffer_data(self):
|
||||
handle, fn = tempfile.mkstemp(prefix="UltiSnips_Test",suffix=".txt")
|
||||
os.close(handle)
|
||||
os.unlink(fn)
|
||||
|
||||
self.send(":w! %s\n" % fn)
|
||||
|
||||
# Read the output, chop the trailing newline
|
||||
tries = 50
|
||||
while tries:
|
||||
if os.path.exists(fn):
|
||||
return open(fn,"r").read()[:-1]
|
||||
time.sleep(.05)
|
||||
tries -= 1
|
||||
|
||||
class VimInterfaceScreen(VimInterface):
|
||||
def __init__(self, session):
|
||||
self.session = session
|
||||
@ -266,20 +281,7 @@ class _VimTest(unittest.TestCase):
|
||||
|
||||
self._options_off()
|
||||
|
||||
handle, fn = tempfile.mkstemp(prefix="UltiSnips_Test",suffix=".txt")
|
||||
os.close(handle)
|
||||
os.unlink(fn)
|
||||
|
||||
self.send(":w! %s\n" % fn)
|
||||
|
||||
# Read the output, chop the trailing newline
|
||||
tries = 50
|
||||
while tries:
|
||||
if os.path.exists(fn):
|
||||
self.output = open(fn,"r").read()[:-1]
|
||||
break
|
||||
time.sleep(.05)
|
||||
tries -= 1
|
||||
self.output = self.vim.get_buffer_data()
|
||||
|
||||
###########################################################################
|
||||
# BEGINNING OF TEST #
|
||||
|
Loading…
x
Reference in New Issue
Block a user