Skip to content

Commit

Permalink
tests/test_terminal.py: Ensure terminal state is restored at end of test
Browse files Browse the repository at this point in the history
test_save, test_save_and_restore_with_dict: Ensure that we restore the
terminal state at the end of each test, as other tests rely on a clean
state to start. Previously, the tests would work the first time but fail
if re-run.

test_save: also compare self.terminal.orig_flags to the current
terminal flags, as opposed to a copy of itself (which would always pass)

Fixes LP: #1817660
  • Loading branch information
lathiat authored and cyphermox committed Mar 7, 2019
1 parent 8b779f9 commit 8a1c46f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion tests/test_terminal.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,10 @@ def test_save(self):
self.terminal.disable_nonblocking_io()
self.assertNotEquals(flags, self.terminal.orig_flags)
self.terminal.reset()
flags = self.terminal.orig_flags
flags = fcntl.fcntl(self.terminal.fd, fcntl.F_GETFL)
self.assertEquals(flags, self.terminal.orig_flags)
self.terminal.disable_nonblocking_io()
self.terminal.save()

def test_save_and_restore_with_dict(self):
self.terminal.enable_nonblocking_io()
Expand All @@ -71,6 +73,7 @@ def test_save_and_restore_with_dict(self):
self.terminal.reset(orig_settings)
flags = fcntl.fcntl(self.terminal.fd, fcntl.F_GETFL)
self.assertEquals(flags, orig_settings.get('flags'))
self.terminal.disable_nonblocking_io()

def test_reset(self):
self.terminal.enable_nonblocking_io()
Expand Down

0 comments on commit 8a1c46f

Please sign in to comment.