(self)
| 621 | tar = self.taropen(tmpname, '') |
| 622 | |
| 623 | def test_fileobj_with_offset(self): |
| 624 | # Skip the first member and store values from the second member |
| 625 | # of the testtar. |
| 626 | tar = tarfile.open(self.tarname, mode=self.mode) |
| 627 | try: |
| 628 | tar.next() |
| 629 | t = tar.next() |
| 630 | name = t.name |
| 631 | offset = t.offset |
| 632 | with tar.extractfile(t) as f: |
| 633 | data = f.read() |
| 634 | finally: |
| 635 | tar.close() |
| 636 | |
| 637 | # Open the testtar and seek to the offset of the second member. |
| 638 | with self.open(self.tarname) as fobj: |
| 639 | fobj.seek(offset) |
| 640 | |
| 641 | # Test if the tarfile starts with the second member. |
| 642 | with tar.open(self.tarname, mode="r:", fileobj=fobj) as tar: |
| 643 | t = tar.next() |
| 644 | self.assertEqual(t.name, name) |
| 645 | # Read to the end of fileobj and test if seeking back to the |
| 646 | # beginning works. |
| 647 | tar.getmembers() |
| 648 | self.assertEqual(tar.extractfile(t).read(), data, |
| 649 | "seek back did not work") |
| 650 | |
| 651 | def test_fail_comp(self): |
| 652 | # For Gzip and Bz2 Tests: fail with a ReadError on an uncompressed file. |
nothing calls this directly
no test coverage detected