Remove unnecessary unicode prefixes
Change-Id: Iaae10962581b84b4ae2af1a064dd27d78c05dd4d
This commit is contained in:
parent
de4429f2be
commit
de2b367b48
@ -43,8 +43,8 @@ source_suffix = '.rst'
|
||||
master_doc = 'index'
|
||||
|
||||
# General information about the project.
|
||||
project = u'oslo.utils'
|
||||
copyright = u'2014, OpenStack Foundation'
|
||||
project = 'oslo.utils'
|
||||
copyright = '2014, OpenStack Foundation'
|
||||
|
||||
# If true, '()' will be appended to :func: etc. cross-reference text.
|
||||
add_function_parentheses = True
|
||||
@ -74,6 +74,6 @@ htmlhelp_basename = '%sdoc' % project
|
||||
latex_documents = [
|
||||
('index',
|
||||
'%s.tex' % project,
|
||||
u'%s Documentation' % project,
|
||||
u'OpenStack Foundation', 'manual'),
|
||||
'%s Documentation' % project,
|
||||
'OpenStack Foundation', 'manual'),
|
||||
]
|
||||
|
@ -303,8 +303,6 @@ def mask_password(message, secret="***"): # nosec
|
||||
'"password" : "***"'
|
||||
>>> mask_password("'original_password' : 'aaaaa'")
|
||||
"'original_password' : '***'"
|
||||
>>> mask_password("u'original_password' : u'aaaaa'")
|
||||
"u'original_password' : u'***'"
|
||||
|
||||
.. versionadded:: 0.2
|
||||
|
||||
|
@ -233,7 +233,6 @@ class NetworkUtilsTest(test_base.BaseTestCase):
|
||||
|
||||
def test_is_valid_mac(self):
|
||||
self.assertTrue(netutils.is_valid_mac("52:54:00:cf:2d:31"))
|
||||
self.assertTrue(netutils.is_valid_mac(u"52:54:00:cf:2d:31"))
|
||||
self.assertFalse(netutils.is_valid_mac("127.0.0.1"))
|
||||
self.assertFalse(netutils.is_valid_mac("not:a:mac:address"))
|
||||
self.assertFalse(netutils.is_valid_mac("52-54-00-cf-2d-31"))
|
||||
|
@ -39,27 +39,27 @@ class SecretUtilsTest(testscenarios.TestWithScenarios,
|
||||
# the built-in function, otherwise that is in vain.
|
||||
ctc = secretutils._constant_time_compare
|
||||
|
||||
self.assertTrue(ctc(self.converter(u'abcd'),
|
||||
self.converter(u'abcd')))
|
||||
self.assertTrue(ctc(self.converter(u''),
|
||||
self.converter(u'')))
|
||||
self.assertTrue(ctc(self.converter('abcd'),
|
||||
self.converter('abcd')))
|
||||
self.assertTrue(ctc(self.converter(''),
|
||||
self.converter('')))
|
||||
self.assertTrue(ctc('abcd', 'abcd'))
|
||||
self.assertFalse(ctc(self.converter(u'abcd'),
|
||||
self.converter(u'efgh')))
|
||||
self.assertFalse(ctc(self.converter(u'abc'),
|
||||
self.converter(u'abcd')))
|
||||
self.assertFalse(ctc(self.converter(u'abc'),
|
||||
self.converter(u'abc\x00')))
|
||||
self.assertFalse(ctc(self.converter(u''),
|
||||
self.converter(u'abc')))
|
||||
self.assertTrue(ctc(self.converter(u'abcd1234'),
|
||||
self.converter(u'abcd1234')))
|
||||
self.assertFalse(ctc(self.converter(u'abcd1234'),
|
||||
self.converter(u'ABCD234')))
|
||||
self.assertFalse(ctc(self.converter(u'abcd1234'),
|
||||
self.converter(u'a')))
|
||||
self.assertFalse(ctc(self.converter(u'abcd1234'),
|
||||
self.converter(u'1234abcd')))
|
||||
self.assertFalse(ctc(self.converter('abcd'),
|
||||
self.converter('efgh')))
|
||||
self.assertFalse(ctc(self.converter('abc'),
|
||||
self.converter('abcd')))
|
||||
self.assertFalse(ctc(self.converter('abc'),
|
||||
self.converter('abc\x00')))
|
||||
self.assertFalse(ctc(self.converter(''),
|
||||
self.converter('abc')))
|
||||
self.assertTrue(ctc(self.converter('abcd1234'),
|
||||
self.converter('abcd1234')))
|
||||
self.assertFalse(ctc(self.converter('abcd1234'),
|
||||
self.converter('ABCD234')))
|
||||
self.assertFalse(ctc(self.converter('abcd1234'),
|
||||
self.converter('a')))
|
||||
self.assertFalse(ctc(self.converter('abcd1234'),
|
||||
self.converter('1234abcd')))
|
||||
self.assertFalse(ctc('abcd1234', '1234abcd'))
|
||||
|
||||
_test_data = "Openstack forever".encode('utf-8')
|
||||
|
@ -77,13 +77,13 @@ class StrUtilsTest(test_base.BaseTestCase):
|
||||
|
||||
def test_unicode_bool_from_string(self):
|
||||
self._test_bool_from_string(str)
|
||||
self.assertFalse(strutils.bool_from_string(u'使用', strict=False))
|
||||
self.assertFalse(strutils.bool_from_string('使用', strict=False))
|
||||
|
||||
exc = self.assertRaises(ValueError, strutils.bool_from_string,
|
||||
u'使用', strict=True)
|
||||
expected_msg = (u"Unrecognized value '使用', acceptable values are:"
|
||||
u" '0', '1', 'f', 'false', 'n', 'no', 'off', 'on',"
|
||||
u" 't', 'true', 'y', 'yes'")
|
||||
'使用', strict=True)
|
||||
expected_msg = ("Unrecognized value '使用', acceptable values are:"
|
||||
" '0', '1', 'f', 'false', 'n', 'no', 'off', 'on',"
|
||||
" 't', 'true', 'y', 'yes'")
|
||||
self.assertEqual(expected_msg, str(exc))
|
||||
|
||||
def test_other_bool_from_string(self):
|
||||
|
@ -96,7 +96,7 @@ class EncodeUtilsTest(test_base.BaseTestCase):
|
||||
def test_to_utf8(self):
|
||||
self.assertEqual(encodeutils.to_utf8(b'a\xe9\xff'), # bytes
|
||||
b'a\xe9\xff')
|
||||
self.assertEqual(encodeutils.to_utf8(u'a\xe9\xff\u20ac'), # Unicode
|
||||
self.assertEqual(encodeutils.to_utf8('a\xe9\xff\u20ac'), # Unicode
|
||||
b'a\xc3\xa9\xc3\xbf\xe2\x82\xac')
|
||||
self.assertRaises(TypeError, encodeutils.to_utf8, 123) # invalid
|
||||
|
||||
@ -112,7 +112,7 @@ class ExceptionToUnicodeTest(test_base.BaseTestCase):
|
||||
|
||||
def test_str_exception(self):
|
||||
# The regular Exception class cannot be used directly:
|
||||
# Exception(u'\xe9').__str__() raises an UnicodeEncodeError
|
||||
# Exception('\xe9').__str__() raises an UnicodeEncodeError
|
||||
# on Python 2
|
||||
class StrException(Exception):
|
||||
def __init__(self, value):
|
||||
@ -129,12 +129,12 @@ class ExceptionToUnicodeTest(test_base.BaseTestCase):
|
||||
# Decode from ASCII
|
||||
exc = StrException(b'bytes ascii')
|
||||
self.assertEqual(encodeutils.exception_to_unicode(exc),
|
||||
u'bytes ascii')
|
||||
'bytes ascii')
|
||||
|
||||
# Decode from UTF-8
|
||||
exc = StrException(b'utf-8 \xc3\xa9\xe2\x82\xac')
|
||||
self.assertEqual(encodeutils.exception_to_unicode(exc),
|
||||
u'utf-8 \xe9\u20ac')
|
||||
'utf-8 \xe9\u20ac')
|
||||
|
||||
# Force the locale encoding to ASCII to test the fallback
|
||||
with mock.patch.object(encodeutils, '_getfilesystemencoding',
|
||||
@ -142,17 +142,17 @@ class ExceptionToUnicodeTest(test_base.BaseTestCase):
|
||||
# Fallback: decode from ISO-8859-1
|
||||
exc = StrException(b'rawbytes \x80\xff')
|
||||
self.assertEqual(encodeutils.exception_to_unicode(exc),
|
||||
u'rawbytes \x80\xff')
|
||||
'rawbytes \x80\xff')
|
||||
|
||||
# No conversion needed
|
||||
exc = StrException(u'unicode ascii')
|
||||
exc = StrException('unicode ascii')
|
||||
self.assertEqual(encodeutils.exception_to_unicode(exc),
|
||||
u'unicode ascii')
|
||||
'unicode ascii')
|
||||
|
||||
# No conversion needed
|
||||
exc = StrException(u'unicode \xe9\u20ac')
|
||||
exc = StrException('unicode \xe9\u20ac')
|
||||
self.assertEqual(encodeutils.exception_to_unicode(exc),
|
||||
u'unicode \xe9\u20ac')
|
||||
'unicode \xe9\u20ac')
|
||||
|
||||
# Test the locale encoding
|
||||
with mock.patch.object(encodeutils, '_getfilesystemencoding',
|
||||
@ -161,10 +161,10 @@ class ExceptionToUnicodeTest(test_base.BaseTestCase):
|
||||
# Decode from the locale encoding
|
||||
# (the message cannot be decoded from ASCII nor UTF-8)
|
||||
self.assertEqual(encodeutils.exception_to_unicode(exc),
|
||||
u'\u0420\u0443\u0441\u0441\u043a\u0438\u0439')
|
||||
'\u0420\u0443\u0441\u0441\u043a\u0438\u0439')
|
||||
|
||||
def test_oslo_i18n_message(self):
|
||||
# use the lazy translation to get a Message instance of oslo_i18n
|
||||
exc = oslo_i18n_fixture.Translation().lazy("test")
|
||||
self.assertEqual(encodeutils.exception_to_unicode(exc),
|
||||
u"test")
|
||||
"test")
|
||||
|
@ -59,7 +59,7 @@ source_suffix = '.rst'
|
||||
master_doc = 'index'
|
||||
|
||||
# General information about the project.
|
||||
copyright = u'2016, oslo.utils Developers'
|
||||
copyright = '2016, oslo.utils Developers'
|
||||
|
||||
# Release notes do not need a version in the title, they span
|
||||
# multiple versions.
|
||||
@ -195,8 +195,8 @@ htmlhelp_basename = 'oslo.utilsReleaseNotesDoc'
|
||||
# author, documentclass [howto, manual, or own class]).
|
||||
latex_documents = [
|
||||
('index', 'oslo.utilsReleaseNotes.tex',
|
||||
u'oslo.utils Release Notes Documentation',
|
||||
u'oslo.utils Developers', 'manual'),
|
||||
'oslo.utils Release Notes Documentation',
|
||||
'oslo.utils Developers', 'manual'),
|
||||
]
|
||||
|
||||
# The name of an image file (relative to this directory) to place at the top of
|
||||
@ -226,8 +226,8 @@ latex_documents = [
|
||||
# (source start file, name, description, authors, manual section).
|
||||
man_pages = [
|
||||
('index', 'oslo.utilsReleaseNotes',
|
||||
u'oslo.utils Release Notes Documentation',
|
||||
[u'oslo.utils Developers'], 1)
|
||||
'oslo.utils Release Notes Documentation',
|
||||
['oslo.utils Developers'], 1)
|
||||
]
|
||||
|
||||
# If true, show URL addresses after external links.
|
||||
@ -240,8 +240,8 @@ man_pages = [
|
||||
# dir menu entry, description, category)
|
||||
texinfo_documents = [
|
||||
('index', 'oslo.utilsReleaseNotes',
|
||||
u'oslo.utils Release Notes Documentation',
|
||||
u'oslo.utils Developers', 'oslo.utilsReleaseNotes',
|
||||
'oslo.utils Release Notes Documentation',
|
||||
'oslo.utils Developers', 'oslo.utilsReleaseNotes',
|
||||
'One line description of project.',
|
||||
'Miscellaneous'),
|
||||
]
|
||||
|
Loading…
Reference in New Issue
Block a user