Exemplo n.º 1
0
 def test_can_make_stream_unseekable(self) -> None:
     """Test can make stream unseekable."""
     fileobj = BytesIO(b"foobar")
     assert seekable(fileobj)
     nonseekable_fileobj = NonSeekableStream(fileobj)
     assert not seekable(nonseekable_fileobj)
     assert nonseekable_fileobj.read() == b"foobar"
Exemplo n.º 2
0
 def test_can_make_stream_unseekable(self):
     fileobj = StringIO("foobar")
     self.assertTrue(seekable(fileobj))
     nonseekable_fileobj = NonSeekableStream(fileobj)
     self.assertFalse(seekable(nonseekable_fileobj))
     self.assertEqual(nonseekable_fileobj.read(), "foobar")
 def test_can_make_stream_unseekable(self):
     fileobj = StringIO('foobar')
     self.assertTrue(seekable(fileobj))
     nonseekable_fileobj = NonSeekableStream(fileobj)
     self.assertFalse(seekable(nonseekable_fileobj))
     self.assertEqual(nonseekable_fileobj.read(), 'foobar')
Exemplo n.º 4
0
 def is_compatible(cls, download_target, osutil):
     return seekable(download_target)
Exemplo n.º 5
0
 def is_compatible(cls, upload_source):
     return readable(upload_source) and seekable(upload_source)
Exemplo n.º 6
0
 def test_non_seekable_oserror(self):
     # Should return False if OSError is thrown.
     with open(self.filename, 'w') as f:
         self.assertFalse(seekable(ErrorRaisingSeekWrapper(f, OSError())))
Exemplo n.º 7
0
 def test_non_file_like_obj(self):
     # Fails becase there is no seekable(), seek(), nor tell()
     self.assertFalse(seekable(object()))
Exemplo n.º 8
0
 def test_seekable_fileobj(self):
     with open(self.filename, 'w') as f:
         self.assertTrue(seekable(f))
Exemplo n.º 9
0
 def test_non_seekable_oserror(self):
     # Should return False if OSError is thrown.
     with open(self.filename, 'w') as f:
         self.assertFalse(seekable(ErrorRaisingSeekWrapper(f, OSError())))
Exemplo n.º 10
0
 def test_non_file_like_obj(self):
     # Fails becase there is no seekable(), seek(), nor tell()
     self.assertFalse(seekable(object()))
Exemplo n.º 11
0
 def test_seekable_fileobj(self):
     with open(self.filename, 'w') as f:
         self.assertTrue(seekable(f))
Exemplo n.º 12
0
 def is_compatible(cls, download_target, osutil):
     return seekable(download_target)