[Python-checkins] bpo-37758: Clean out vestigial script-bits from test_unicodedata. (GH-15126)

Benjamin Peterson webhook-mailer at python.org
Tue Aug 13 01:58:05 EDT 2019


https://github.com/python/cpython/commit/def97c988be8340f33869b57942a30d10fc3a1f9
commit: def97c988be8340f33869b57942a30d10fc3a1f9
branch: master
author: Greg Price <gnprice at gmail.com>
committer: Benjamin Peterson <benjamin at python.org>
date: 2019-08-12T22:58:01-07:00
summary:

bpo-37758: Clean out vestigial script-bits from test_unicodedata. (GH-15126)

This file started life as a script, before conversion to a
`unittest` test file.  Clear out some legacies of that conversion
that are a bit confusing about how it works.

Most notably, it's unlikely there's still a good reason to try
to recover from `unicodedata` failing to import -- as there was
when that logic was first added, when the module was very new.
So take that out entirely.  Keep `self.db` working, though, to
avoid a noisy diff.

files:
M Lib/test/test_unicodedata.py

diff --git a/Lib/test/test_unicodedata.py b/Lib/test/test_unicodedata.py
index a52b6de547fb..7bc196be362b 100644
--- a/Lib/test/test_unicodedata.py
+++ b/Lib/test/test_unicodedata.py
@@ -1,4 +1,4 @@
-""" Test script for the unicodedata module.
+""" Tests for the unicodedata module.
 
     Written by Marc-Andre Lemburg (mal at lemburg.com).
 
@@ -6,16 +6,12 @@
 
 """
 
+import hashlib
 import sys
+import unicodedata
 import unittest
-import hashlib
 from test.support import script_helper
 
-encoding = 'utf-8'
-errors = 'surrogatepass'
-
-
-### Run tests
 
 class UnicodeMethodsTest(unittest.TestCase):
 
@@ -61,20 +57,12 @@ def test_method_checksum(self):
                 (char + 'ABC').title(),
 
                 ]
-            h.update(''.join(data).encode(encoding, errors))
+            h.update(''.join(data).encode('utf-8', 'surrogatepass'))
         result = h.hexdigest()
         self.assertEqual(result, self.expectedchecksum)
 
 class UnicodeDatabaseTest(unittest.TestCase):
-
-    def setUp(self):
-        # In case unicodedata is not available, this will raise an ImportError,
-        # but the other test cases will still be run
-        import unicodedata
-        self.db = unicodedata
-
-    def tearDown(self):
-        del self.db
+    db = unicodedata
 
 class UnicodeFunctionsTest(UnicodeDatabaseTest):
 



More information about the Python-checkins mailing list