Example #1
0
 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()
Example #2
0
 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()
Example #3
0
 def test_tell(self):
     with open(self.filename, 'rb') as f:
         reader = InterruptReader(f, self.transfer_coordinator)
         # Ensure it can tell correctly
         reader.seek(1)
         self.assertEqual(reader.tell(), 1)
Example #4
0
 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])
Example #5
0
 def test_tell(self):
     with open(self.filename, 'rb') as f:
         reader = InterruptReader(f, self.transfer_coordinator)
         # Ensure it can tell correctly
         reader.seek(1)
         self.assertEqual(reader.tell(), 1)
Example #6
0
 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])