This fixes a missing .lower() on the encoding name, a wrong byte undecodable by UTF-8, a wrong variable name, hopefully some windows buildbot on 3.x and adds a proper skip. It might break other things though.

This commit is contained in:
Ezio Melotti 2010-03-05 12:43:17 +00:00
parent 5a53fdeee8
commit 9a7d5ac9f6
1 changed files with 40 additions and 37 deletions

View File

@ -85,13 +85,14 @@ class ImportTests(unittest.TestCase):
# and issue never happens for dynamic modules.
# But sources modified to follow generic way for processing pathes.
locale_encoding = locale.getpreferredencoding()
# the return encoding can be uppercase
locale_encoding = locale.getpreferredencoding().lower()
# covers utf-8 and Windows ANSI code pages
# one non-space symbol from every page
# (http://en.wikipedia.org/wiki/Code_page)
known_locales = {
'utf-8' : b'\xe4',
'utf-8' : b'\xc3\xa4',
'cp1250' : b'\x8C',
'cp1251' : b'\xc0',
'cp1252' : b'\xc0',
@ -104,10 +105,12 @@ class ImportTests(unittest.TestCase):
}
special_char = known_locales.get(locale_encoding)
if special_char:
encoded_char = special_char.decode(locale_encoding)
temp_mod_name = 'test_imp_helper_' + encoded_char
test_package_name = 'test_imp_helper_package_' + encoded_char
if not special_char:
self.skipTest("can't run this test with %s as preferred encoding"
% locale_encoding)
decoded_char = special_char.decode(locale_encoding)
temp_mod_name = 'test_imp_helper_' + decoded_char
test_package_name = 'test_imp_helper_package_' + decoded_char
init_file_name = os.path.join(test_package_name, '__init__.py')
try:
with open(temp_mod_name + '.py', 'w') as file: