mirror of
https://github.com/python/cpython.git
synced 2025-08-31 14:07:50 +00:00
Merged revisions 59259-59274 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r59260 | lars.gustaebel | 2007-12-01 22:02:12 +0100 (Sat, 01 Dec 2007) | 5 lines Issue #1531: Read fileobj from the current offset, do not seek to the start. (will backport to 2.5) ........ r59262 | georg.brandl | 2007-12-01 23:24:47 +0100 (Sat, 01 Dec 2007) | 4 lines Document PyEval_* functions from ceval.c. Credits to Michael Sloan from GHOP. ........ r59263 | georg.brandl | 2007-12-01 23:27:56 +0100 (Sat, 01 Dec 2007) | 2 lines Add a few refcount data entries. ........ r59264 | georg.brandl | 2007-12-01 23:38:48 +0100 (Sat, 01 Dec 2007) | 4 lines Add test suite for cmd module. Written by Michael Schneider for GHOP. ........ r59265 | georg.brandl | 2007-12-01 23:42:46 +0100 (Sat, 01 Dec 2007) | 3 lines Add examples to the ElementTree documentation. Written by h4wk.cz for GHOP. ........ r59266 | georg.brandl | 2007-12-02 00:12:45 +0100 (Sun, 02 Dec 2007) | 3 lines Add "Using Python on Windows" document, by Robert Lehmann. Written for GHOP. ........ r59271 | georg.brandl | 2007-12-02 15:34:34 +0100 (Sun, 02 Dec 2007) | 3 lines Add example to mmap docs. Written for GHOP by Rafal Rawicki. ........ r59272 | georg.brandl | 2007-12-02 15:37:29 +0100 (Sun, 02 Dec 2007) | 2 lines Convert bdb.rst line endings to Unix style. ........ r59274 | georg.brandl | 2007-12-02 15:58:50 +0100 (Sun, 02 Dec 2007) | 4 lines Add more entries to the glossary. Written by Jeff Wheeler for GHOP. ........
This commit is contained in:
parent
b27ce7e468
commit
d8654cf758
35 changed files with 1314 additions and 432 deletions
|
@ -159,6 +159,38 @@ class MiscReadTest(ReadTest):
|
|||
tar = tarfile.open(fileobj=fobj, mode=self.mode)
|
||||
self.assertEqual(tar.name, None)
|
||||
|
||||
def test_fileobj_with_offset(self):
|
||||
# Skip the first member and store values from the second member
|
||||
# of the testtar.
|
||||
tar = tarfile.open(self.tarname, mode=self.mode)
|
||||
tar.next()
|
||||
t = tar.next()
|
||||
name = t.name
|
||||
offset = t.offset
|
||||
data = tar.extractfile(t).read()
|
||||
tar.close()
|
||||
|
||||
# Open the testtar and seek to the offset of the second member.
|
||||
if self.mode.endswith(":gz"):
|
||||
_open = gzip.GzipFile
|
||||
elif self.mode.endswith(":bz2"):
|
||||
_open = bz2.BZ2File
|
||||
else:
|
||||
_open = open
|
||||
fobj = _open(self.tarname, "rb")
|
||||
fobj.seek(offset)
|
||||
|
||||
# Test if the tarfile starts with the second member.
|
||||
tar = tar.open(self.tarname, mode="r:", fileobj=fobj)
|
||||
t = tar.next()
|
||||
self.assertEqual(t.name, name)
|
||||
# Read to the end of fileobj and test if seeking back to the
|
||||
# beginning works.
|
||||
tar.getmembers()
|
||||
self.assertEqual(tar.extractfile(t).read(), data,
|
||||
"seek back did not work")
|
||||
tar.close()
|
||||
|
||||
def test_fail_comp(self):
|
||||
# For Gzip and Bz2 Tests: fail with a ReadError on an uncompressed file.
|
||||
if self.mode == "r:":
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue