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"
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')
def is_compatible(cls, download_target, osutil): return seekable(download_target)
def is_compatible(cls, upload_source): return readable(upload_source) and seekable(upload_source)
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())))
def test_non_file_like_obj(self): # Fails becase there is no seekable(), seek(), nor tell() self.assertFalse(seekable(object()))
def test_seekable_fileobj(self): with open(self.filename, 'w') as f: self.assertTrue(seekable(f))