diff --git a/tests/test_command_list_split.py b/tests/test_command_list_split.py index 66bf26a..9ae5396 100644 --- a/tests/test_command_list_split.py +++ b/tests/test_command_list_split.py @@ -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) diff --git a/wexpect.py b/wexpect.py index d756252..cc6f1b0 100644 --- a/wexpect.py +++ b/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."""