[Python-checkins] cpython: Build a list of supported test tarfiles dynamically for CLI "test" command

serhiy.storchaka python-checkins at python.org
Sun Nov 24 01:32:47 CET 2013


http://hg.python.org/cpython/rev/70b9d22b900a
changeset:   87475:70b9d22b900a
user:        Serhiy Storchaka <storchaka at gmail.com>
date:        Sun Nov 24 02:30:59 2013 +0200
summary:
  Build a list of supported test tarfiles dynamically for CLI "test" command
tests (issue13477).

files:
  Lib/test/test_tarfile.py |  9 ++++++---
  1 files changed, 6 insertions(+), 3 deletions(-)


diff --git a/Lib/test/test_tarfile.py b/Lib/test/test_tarfile.py
--- a/Lib/test/test_tarfile.py
+++ b/Lib/test/test_tarfile.py
@@ -1745,13 +1745,13 @@
                 tf.add(tardata, arcname=os.path.basename(tardata))
 
     def test_test_command(self):
-        for tar_name in (tarname, gzipname, bz2name, xzname):
+        for tar_name in testtarnames:
             for opt in '-t', '--test':
                 out = self.tarfilecmd(opt, tar_name)
                 self.assertEqual(out, b'')
 
     def test_test_command_verbose(self):
-        for tar_name in (tarname, gzipname, bz2name, xzname):
+        for tar_name in testtarnames:
             for opt in '-v', '--verbose':
                 out = self.tarfilecmd(opt, '-t', tar_name)
                 self.assertIn(b'is a tar archive.\n', out)
@@ -1763,7 +1763,7 @@
         self.assertEqual(out, b'')
         self.assertEqual(rc, 1)
 
-        for tar_name in (tarname, gzipname, bz2name, xzname):
+        for tar_name in testtarnames:
             with self.subTest(tar_name=tar_name):
                 with open(tar_name, 'rb') as f:
                     data = f.read()
@@ -2015,6 +2015,8 @@
     support.unlink(TEMPDIR)
     os.makedirs(TEMPDIR)
 
+    global testtarnames
+    testtarnames = [tarname]
     with open(tarname, "rb") as fobj:
         data = fobj.read()
 
@@ -2022,6 +2024,7 @@
     for c in GzipTest, Bz2Test, LzmaTest:
         if c.open:
             support.unlink(c.tarname)
+            testtarnames.append(c.tarname)
             with c.open(c.tarname, "wb") as tar:
                 tar.write(data)
 

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list