Ejemplo n.º 1
0
 def returns_1_when_stream_has_fileno_but_is_not_a_tty(self, fcntl):
     # It blows up otherwise anyways (struct.unpack gets mad because
     # result isn't a string of the right length) but let's make
     # ioctl die similarly to the real world case we're testing for
     # here (#425)
     fcntl.ioctl.side_effect = IOError(
         "Operation not supported by device")
     stream = Mock(isatty=lambda: False, fileno=lambda: 17)  # arbitrary
     assert bytes_to_read(stream) == 1
     assert not fcntl.ioctl.called
Ejemplo n.º 2
0
 def returns_1_when_stream_has_fileno_but_is_not_a_tty(self, fcntl):
     # It blows up otherwise anyways (struct.unpack gets mad because
     # result isn't a string of the right length) but let's make
     # ioctl die similarly to the real world case we're testing for
     # here (#425)
     fcntl.ioctl.side_effect = IOError(
         "Operation not supported by device"
     )
     stream = Mock(isatty=lambda: False, fileno=lambda: 17)  # arbitrary
     assert bytes_to_read(stream) == 1
     assert not fcntl.ioctl.called
Ejemplo n.º 3
0
 def returns_1_when_stream_lacks_fileno(self, fcntl):
     # A fileno() that exists but returns a non-int is a quick way
     # to fail util.has_fileno().
     assert bytes_to_read(Mock(fileno=lambda: None)) == 1
     assert not fcntl.ioctl.called
Ejemplo n.º 4
0
 def returns_1_when_stream_lacks_fileno(self, fcntl):
     # A fileno() that exists but returns a non-int is a quick way
     # to fail util.has_fileno().
     assert bytes_to_read(Mock(fileno=lambda: None)) == 1
     assert not fcntl.ioctl.called