diff -r 657caf5d3eb1 Lib/test/test_tarfile.py --- a/Lib/test/test_tarfile.py Mon Dec 03 16:13:48 2012 +0200 +++ b/Lib/test/test_tarfile.py Mon Dec 03 22:57:58 2012 +0000 @@ -1812,6 +1812,31 @@ def test_partial_input_bz2(self): self._test_partial_input("r:bz2") +class PartialIterTest(unittest.TestCase): + + specialFile = 'specialFile.txt' + + def setUp(self): + self.files = ['file%d.txt' % a for a in range(5)] + self.files.insert(2, self.specialFile) + datapath = os.path.join(TEMPDIR, 'partialiter.dat') + with open(datapath, 'w') as f: + f.write('somedata') + + self.tarpath = os.path.join(TEMPDIR, 'partialiter.tar') + with tarfile.open(self.tarpath, 'w') as tf: + for f in self.files: + tf.add(datapath, f) + + def test_partial_iterate(self): + + with tarfile.open(self.tarpath) as tf: + for member in tf: + if member.name == self.specialFile: + break + + self.assertEqual([member.name for member in tf], self.files) + class LzmaMiscReadTest(MiscReadTest): tarname = xzname @@ -1851,6 +1876,7 @@ LimitsTest, MiscTest, ContextManagerTest, + PartialIterTest, ] if hasattr(os, "link"):