]> granicus.if.org Git - python/commitdiff
merge from 3.1
authorSenthil Kumaran <senthil@uthcode.com>
Thu, 28 Apr 2011 09:08:12 +0000 (17:08 +0800)
committerSenthil Kumaran <senthil@uthcode.com>
Thu, 28 Apr 2011 09:08:12 +0000 (17:08 +0800)
1  2 
Lib/test/test_tarfile.py

index e3e140e59e4891b838ea0845a867275b27dcd597,a086c635eddc9051dad72de4f490af572a275d36..f363f701cb19921c2c8dac84d96f702ec9db44b6
@@@ -327,30 -230,26 +327,31 @@@ class MiscReadTest(CommonReadTest)
          # Test hardlink extraction (e.g. bug #857297).
          tar = tarfile.open(tarname, errorlevel=1, encoding="iso8859-1")
  
 -        tar.extract("ustar/regtype", TEMPDIR)
          try:
 -            tar.extract("ustar/lnktype", TEMPDIR)
 -        except EnvironmentError as e:
 -            if e.errno == errno.ENOENT:
 -                self.fail("hardlink not extracted properly")
 -
 -        data = open(os.path.join(TEMPDIR, "ustar/lnktype"), "rb").read()
 -        self.assertEqual(md5sum(data), md5_regtype)
 +            tar.extract("ustar/regtype", TEMPDIR)
 +            try:
 +                tar.extract("ustar/lnktype", TEMPDIR)
 +            except EnvironmentError as e:
 +                if e.errno == errno.ENOENT:
 +                    self.fail("hardlink not extracted properly")
  
 -        try:
 -            tar.extract("ustar/symtype", TEMPDIR)
 -        except EnvironmentError as e:
 -            if e.errno == errno.ENOENT:
 -                self.fail("symlink not extracted properly")
 +            with open(os.path.join(TEMPDIR, "ustar/lnktype"), "rb") as f:
 +                data = f.read()
 +            self.assertEqual(md5sum(data), md5_regtype)
  
 -        data = open(os.path.join(TEMPDIR, "ustar/symtype"), "rb").read()
 -        self.assertEqual(md5sum(data), md5_regtype)
 +            try:
 +                tar.extract("ustar/symtype", TEMPDIR)
 +            except EnvironmentError as e:
 +                if e.errno == errno.ENOENT:
 +                    self.fail("symlink not extracted properly")
 +
 +            with open(os.path.join(TEMPDIR, "ustar/symtype"), "rb") as f:
 +                data = f.read()
 +            self.assertEqual(md5sum(data), md5_regtype)
 +        finally:
 +            tar.close()
  
 -    @unittest.skipUnless(hasattr(os,'symlink'), "needs os.symlink")
++    @support.skip_unless_symlink
      def test_extractall(self):
          # Test if extractall() correctly restores directory permissions
          # and times (see issue1735).