From 21e9c58b9a33b7a1a2b304fe82445052c94eb20d Mon Sep 17 00:00:00 2001 From: Philip Thiem Date: Thu, 24 Apr 2014 08:07:17 -0500 Subject: ensure write_manifest passes contents to write_file as unicode strings. --HG-- extra : rebase_source : 719fb2eb2c3599c57d7a11f5fc55cf9a88d74df7 --- setuptools/tests/test_sdist.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'setuptools/tests/test_sdist.py') diff --git a/setuptools/tests/test_sdist.py b/setuptools/tests/test_sdist.py index 71d10757..09a58621 100644 --- a/setuptools/tests/test_sdist.py +++ b/setuptools/tests/test_sdist.py @@ -156,10 +156,11 @@ class TestSdistTest(unittest.TestCase): self.fail(e) # The manifest should contain the UTF-8 filename - if sys.version_info >= (3,): - self.assertTrue(posix(filename) in u_contents) - else: - self.assertTrue(posix(filename) in contents) + if sys.version_info < (3,): + fs_enc = sys.getfilesystemencoding() + filename = filename.decode(fs_enc) + + self.assertTrue(posix(filename) in u_contents) # Python 3 only if sys.version_info >= (3,): -- cgit v1.2.1 From b9a53c47f66dbc41e3e9ba8bd29932d1ca6a589f Mon Sep 17 00:00:00 2001 From: Philip Thiem Date: Thu, 24 Apr 2014 23:06:09 -0500 Subject: test_sdist: change the latin1 test to match the behavior of write_manifest --- setuptools/tests/test_sdist.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'setuptools/tests/test_sdist.py') diff --git a/setuptools/tests/test_sdist.py b/setuptools/tests/test_sdist.py index 09a58621..31768e21 100644 --- a/setuptools/tests/test_sdist.py +++ b/setuptools/tests/test_sdist.py @@ -397,9 +397,20 @@ class TestSdistTest(unittest.TestCase): filename = filename.decode('latin-1') self.assertFalse(filename in cmd.filelist.files) else: - # No conversion takes place under Python 2 and the file - # is included. We shall keep it that way for BBB. - self.assertTrue(filename in cmd.filelist.files) + # Under Python 2 there seems to be no decoding of the + # filelist. However, due to decode and encoding of the + # file name to utf-8 + try: + #This seems a bit iffy, but not really what else + #since cmd.filelist.files is not encoded, but + #want to write out the manifest as UTF-8/ + + #This is how one expected the filename to be decoded + fs_enc = sys.getfilesystemencoding() + filename.decode(fs_enc) + self.assertTrue(filename in cmd.filelist.files) + except UnicodeDecodeError: + self.assertFalse(filename in cmd.filelist.files) class TestDummyOutput(environment.ZippedEnvironment): -- cgit v1.2.1 From 7192c0fb9e77a8ffa8f54b956cb6775ecb3b1795 Mon Sep 17 00:00:00 2001 From: philip_thiem Date: Fri, 25 Apr 2014 04:53:11 +0000 Subject: Improved comment in the latin1 sdist test. --- setuptools/tests/test_sdist.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'setuptools/tests/test_sdist.py') diff --git a/setuptools/tests/test_sdist.py b/setuptools/tests/test_sdist.py index 31768e21..5d8340b0 100644 --- a/setuptools/tests/test_sdist.py +++ b/setuptools/tests/test_sdist.py @@ -397,15 +397,12 @@ class TestSdistTest(unittest.TestCase): filename = filename.decode('latin-1') self.assertFalse(filename in cmd.filelist.files) else: - # Under Python 2 there seems to be no decoding of the + # Under Python 2 there seems to be no decoded string in the # filelist. However, due to decode and encoding of the - # file name to utf-8 + # file name to get utf-8 Manifest the latin1 maybe excluded try: - #This seems a bit iffy, but not really what else - #since cmd.filelist.files is not encoded, but - #want to write out the manifest as UTF-8/ - - #This is how one expected the filename to be decoded + # fs_enc should match how one is expect the decoding to + # be proformed for the manifest output. fs_enc = sys.getfilesystemencoding() filename.decode(fs_enc) self.assertTrue(filename in cmd.filelist.files) -- cgit v1.2.1