Skip to content

Commit

Permalink
improve, add test
Browse files Browse the repository at this point in the history
  • Loading branch information
blueyed committed Oct 25, 2019
1 parent 4e06dd5 commit 5a25372
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
5 changes: 2 additions & 3 deletions pyrepl/unix_console.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,9 +356,8 @@ def prepare(self):
# per-readline preparations:
try:
self.__svtermstate = tcgetattr(self.input_fd)
except termios.error: # (25, 'Inappropriate ioctl for device')
# assert not os.fdopen(self.input_fd).isatty()
raise EOFError
except termios.error as exc:
raise EOFError("could not prepare fd %d: %s" % (self.input_fd, exc))
self._prepared = True
raw = self.__svtermstate.copy()
raw.iflag |= termios.ICRNL
Expand Down
12 changes: 12 additions & 0 deletions testing/test_unix_console.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import pytest


def test_eoferror():
from pyrepl.unix_console import UnixConsole

console = UnixConsole(f_in=99)
with pytest.raises(
EOFError,
match="^could not prepare fd 99: .*Bad file descriptor"
):
console.prepare()

0 comments on commit 5a25372

Please sign in to comment.