Issue #11638: Adding test to ensure .tar.gz files can be generated by sdist command with unicode metadata, based on David Barnett's patch.

Issue #11638: Added tests to capture failures in make_tarball with various unicode strings.
Following fix for Issue #13639, these tests now pass.
This commit is contained in:
Jason R. Coombs 2011-12-26 10:15:15 -05:00
parent 2c9eee1af9
commit 042370e750
3 changed files with 54 additions and 2 deletions

View file

@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
"""Tests for distutils.archive_util."""
__revision__ = "$Id$"
@ -40,6 +41,9 @@ class ArchiveUtilTestCase(support.TempdirManager,
@unittest.skipUnless(zlib, "requires zlib")
def test_make_tarball(self):
self._make_tarball('archive')
def _make_tarball(self, target_name):
# creating something to tar
tmpdir = self.mkdtemp()
self.write_file([tmpdir, 'file1'], 'xxx')
@ -51,7 +55,7 @@ class ArchiveUtilTestCase(support.TempdirManager,
unittest.skipUnless(splitdrive(tmpdir)[0] == splitdrive(tmpdir2)[0],
"source and target should be on same drive")
base_name = os.path.join(tmpdir2, 'archive')
base_name = os.path.join(tmpdir2, target_name)
# working with relative paths to avoid tar warnings
old_dir = os.getcwd()
@ -66,7 +70,7 @@ class ArchiveUtilTestCase(support.TempdirManager,
self.assertTrue(os.path.exists(tarball))
# trying an uncompressed one
base_name = os.path.join(tmpdir2, 'archive')
base_name = os.path.join(tmpdir2, target_name)
old_dir = os.getcwd()
os.chdir(tmpdir)
try:
@ -277,6 +281,29 @@ class ArchiveUtilTestCase(support.TempdirManager,
finally:
del ARCHIVE_FORMATS['xxx']
@unittest.skipUnless(zlib, "requires zlib")
def test_make_tarball_unicode(self):
"""
Mirror test_make_tarball, except filename is unicode.
"""
self._make_tarball(u'archive')
@unittest.skipUnless(zlib, "requires zlib")
def test_make_tarball_unicode_latin1(self):
"""
Mirror test_make_tarball, except filename is unicode and contains
latin characters.
"""
self._make_tarball(u'årchiv') # note this isn't a real word
@unittest.skipUnless(zlib, "requires zlib")
def test_make_tarball_unicode_extended(self):
"""
Mirror test_make_tarball, except filename is unicode and contains
characters outside the latin charset.
"""
self._make_tarball(u'のアーカイブ') # japanese for archive
def test_suite():
return unittest.makeSuite(ArchiveUtilTestCase)