[Python-checkins] distutils2: Add tests for Unicode handling in check and register (#13114).

eric.araujo python-checkins at python.org
Wed Oct 12 18:09:19 CEST 2011


http://hg.python.org/distutils2/rev/c4392e526e85
changeset:   1210:c4392e526e85
parent:      1207:0d838447c4ab
user:        Éric Araujo <merwok at netwok.org>
date:        Tue Oct 11 02:30:39 2011 +0200
summary:
  Add tests for Unicode handling in check and register (#13114).

Contrary to distutils in Python 2.7, distutils2 does not have the bugs.
Developing with Python 3 and porting to 2.x just rocks like that.

files:
  distutils2/tests/test_command_check.py    |  25 ++++++++++-
  distutils2/tests/test_command_register.py |  15 ++++++
  runtests.py                               |   1 +
  3 files changed, 39 insertions(+), 2 deletions(-)


diff --git a/distutils2/tests/test_command_check.py b/distutils2/tests/test_command_check.py
--- a/distutils2/tests/test_command_check.py
+++ b/distutils2/tests/test_command_check.py
@@ -56,6 +56,15 @@
         cmd = self._run(metadata, strict=True)
         self.assertEqual([], self.get_logs(logging.WARNING))
 
+        # now a test with non-ASCII characters
+        metadata = {'home_page': u'xxx', 'author': u'\u00c9ric',
+                    'author_email': u'xxx', 'name': u'xxx',
+                    'version': u'1.2',
+                    'summary': u'Something about esszet \u00df',
+                    'description': u'More things about esszet \u00df'}
+        cmd = self._run(metadata)
+        self.assertEqual([], self.get_logs(logging.WARNING))
+
     def test_check_metadata_1_2(self):
         # let's run the command with no metadata at all
         # by default, check is checking the metadata
@@ -95,14 +104,26 @@
 
     @unittest.skipUnless(_HAS_DOCUTILS, "requires docutils")
     def test_check_restructuredtext(self):
-        # let's see if it detects broken rest in long_description
+        # let's see if it detects broken rest in description
         broken_rest = 'title\n===\n\ntest'
         pkg_info, dist = self.create_dist(description=broken_rest)
         cmd = check(dist)
         cmd.check_restructuredtext()
         self.assertEqual(len(self.get_logs(logging.WARNING)), 1)
+        # clear warnings from the previous call
+        self.loghandler.flush()
 
-        pkg_info, dist = self.create_dist(description='title\n=====\n\ntest')
+        # let's see if we have an error with strict=1
+        metadata = {'home_page': 'xxx', 'author': 'xxx',
+                    'author_email': 'xxx',
+                    'name': 'xxx', 'version': '1.2',
+                    'description': broken_rest}
+        self.assertRaises(PackagingSetupError, self._run, metadata,
+                          strict=True, all=True)
+        self.loghandler.flush()
+
+        # and non-broken rest, including a non-ASCII character to test #12114
+        dist = self.create_dist(description=u'title\n=====\n\ntest \u00df')[1]
         cmd = check(dist)
         cmd.check_restructuredtext()
         self.assertEqual([], self.get_logs(logging.WARNING))
diff --git a/distutils2/tests/test_command_register.py b/distutils2/tests/test_command_register.py
--- a/distutils2/tests/test_command_register.py
+++ b/distutils2/tests/test_command_register.py
@@ -244,6 +244,21 @@
         cmd.ensure_finalized()
         cmd.run()
 
+        # and finally a Unicode test (bug #12114)
+        metadata = {'home_page': u'xxx', 'author': u'\u00c9ric',
+                    'author_email': u'xxx', 'name': u'xxx',
+                    'version': u'xxx',
+                    'summary': u'Something about esszet \u00df',
+                    'description': u'More things about esszet \u00df'}
+
+        cmd = self._get_cmd(metadata)
+        cmd.ensure_finalized()
+        cmd.strict = True
+        inputs = Inputs('1', 'tarek', 'y')
+        register_module.raw_input = inputs
+        cmd.ensure_finalized()
+        cmd.run()
+
     def test_register_pep345(self):
         cmd = self._get_cmd({})
         cmd.ensure_finalized()
diff --git a/runtests.py b/runtests.py
--- a/runtests.py
+++ b/runtests.py
@@ -95,6 +95,7 @@
 
 def test_main():
     opts, args = parse_opts()
+    # FIXME when we run with --quiet, we still want to see errors and failures
     verbose = not opts.quiet
     ret = 0
 

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


More information about the Python-checkins mailing list