def test_read_raises_exception(self): with open(self.filename, 'rb') as f: reader = InterruptReader(f, self.transfer_coordinator) # Read some bytes to show it can be read. self.assertEqual(reader.read(1), self.content[0:1]) # Then set an exception in the transfer coordinator self.transfer_coordinator.set_exception(InterruptionError()) # The next read should have the exception propograte with self.assertRaises(InterruptionError): reader.read()
def test_seek(self): with open(self.filename, 'rb') as f: reader = InterruptReader(f, self.transfer_coordinator) # Ensure it can seek correctly reader.seek(1) self.assertEqual(reader.read(1), self.content[1:2])