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