Skip to content

Commit

Permalink
improve, add test
Browse files Browse the repository at this point in the history
  • Loading branch information
blueyed committed Apr 11, 2021
1 parent d5e126d commit 7349f1a
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 7349f1a

Please sign in to comment.