Ejemplo n.º 1
0
 def test_seek_too_far_real_file(self):
     # StringIO doesn't raise IOError if you see past the start of the file.
     with tempfile.TemporaryFile() as flo:
         content = b'1234567890'
         flo.write(content)
         self.assertEqual(
             (content, 0),
             libvirt_utils.last_bytes(flo, 1000))
Ejemplo n.º 2
0
 def test_read_all(self):
     self.f.seek(0, os.SEEK_SET)
     out, remaining = libvirt_utils.last_bytes(self.f, 1000)
     self.assertEqual(out, b'1234567890')
     self.assertFalse(remaining > 0)
Ejemplo n.º 3
0
 def test_truncated(self):
     self.f.seek(0, os.SEEK_SET)
     out, remaining = libvirt_utils.last_bytes(self.f, 5)
     self.assertEqual(out, b'67890')
     self.assertGreater(remaining, 0)
Ejemplo n.º 4
0
def last_bytes(file_like_object, num):
    return libvirt_utils.last_bytes(file_like_object, num)
Ejemplo n.º 5
0
 def test_read_all(self):
     self.f.seek(0, os.SEEK_SET)
     out, remaining = libvirt_utils.last_bytes(self.f, 1000)
     self.assertEqual(out, b'1234567890')
     self.assertFalse(remaining > 0)
Ejemplo n.º 6
0
 def test_truncated(self):
     self.f.seek(0, os.SEEK_SET)
     out, remaining = libvirt_utils.last_bytes(self.f, 5)
     self.assertEqual(out, b'67890')
     self.assertGreater(remaining, 0)
Ejemplo n.º 7
0
def last_bytes(file_like_object, num):
    return libvirt_utils.last_bytes(file_like_object, num)