mirror of
https://github.com/clearml/wexpect-venv
synced 2025-03-13 06:58:10 +00:00
[CLN] try - finally blocks
This commit is contained in:
parent
b9ab8d76a0
commit
f2822c0d42
@ -24,17 +24,17 @@ from . import PexpectTestCase
|
||||
|
||||
class SplitCommandLineTestCase(PexpectTestCase.PexpectTestCase):
|
||||
def testSplitSizes(self):
|
||||
assert len(wexpect.split_command_line(r'')) == 0
|
||||
assert len(wexpect.split_command_line(r'one')) == 1
|
||||
assert len(wexpect.split_command_line(r'one two')) == 2
|
||||
assert len(wexpect.split_command_line(r'one two')) == 2
|
||||
assert len(wexpect.split_command_line(r'one two')) == 2
|
||||
assert len(wexpect.split_command_line(r'one^ one')) == 1
|
||||
assert len(wexpect.split_command_line('\'one one\'')) == 1
|
||||
assert len(wexpect.split_command_line(r'one\"one')) == 1
|
||||
assert len(wexpect.split_command_line(r"This^' is a^'^ test")) == 3
|
||||
self.assertEqual(len(wexpect.split_command_line(r'')), 0)
|
||||
self.assertEqual(len(wexpect.split_command_line(r'one')), 1)
|
||||
self.assertEqual(len(wexpect.split_command_line(r'one two')), 2)
|
||||
self.assertEqual(len(wexpect.split_command_line(r'one two')), 2)
|
||||
self.assertEqual(len(wexpect.split_command_line(r'one two')), 2)
|
||||
self.assertEqual(len(wexpect.split_command_line(r'one^ one')), 1)
|
||||
self.assertEqual(len(wexpect.split_command_line('\'one one\'')), 1)
|
||||
self.assertEqual(len(wexpect.split_command_line(r'one\"one')), 1)
|
||||
self.assertEqual(len(wexpect.split_command_line(r"This^' is a^'^ test")), 3)
|
||||
|
||||
def test_join_args(self):
|
||||
def testJoinArgs(self):
|
||||
cmd = 'foo bar "b a z"'
|
||||
cmd2 = wexpect.join_args(wexpect.split_command_line(cmd))
|
||||
self.assertEqual(cmd2, cmd)
|
||||
|
12
wexpect.py
12
wexpect.py
@ -1655,10 +1655,8 @@ class Wtty:
|
||||
try:
|
||||
mode = self.__consin.GetConsoleMode()
|
||||
ret = (mode & 0x0004) > 0
|
||||
finally:
|
||||
self.switchBack()
|
||||
except:
|
||||
self.switchBack()
|
||||
raise
|
||||
return ret
|
||||
|
||||
def getwinsize(self):
|
||||
@ -1668,10 +1666,8 @@ class Wtty:
|
||||
self.switchTo()
|
||||
try:
|
||||
size = self.__consout.GetConsoleScreenBufferInfo()['Size']
|
||||
finally:
|
||||
self.switchBack()
|
||||
except:
|
||||
self.switchBack()
|
||||
raise
|
||||
return (size.Y, size.X)
|
||||
|
||||
def setwinsize(self, r, c):
|
||||
@ -1680,10 +1676,8 @@ class Wtty:
|
||||
self.switchTo()
|
||||
try:
|
||||
self.__consout.SetConsoleScreenBufferSize(win32console.PyCOORDType(c, r))
|
||||
except:
|
||||
finally:
|
||||
self.switchBack()
|
||||
raise
|
||||
self.switchBack()
|
||||
|
||||
def interact(self):
|
||||
"""Displays the child console for interaction."""
|
||||
|
Loading…
Reference in New Issue
Block a user