diff options
author | Jan Cholasta <jcholast@redhat.com> | 2015-09-01 13:22:04 +0200 |
---|---|---|
committer | Jan Cholasta <jcholast@redhat.com> | 2015-09-17 11:08:43 +0200 |
commit | 33aba6f35e43b5febf1751de4cef2863749f93e7 (patch) | |
tree | f0aef38d28375a2486047b6e72f1cb13c47d7806 /ipatests | |
parent | ba5201979dfddcb4ca6bb1b68e786cb964e50bb6 (diff) | |
download | freeipa-33aba6f35e43b5febf1751de4cef2863749f93e7.tar.gz freeipa-33aba6f35e43b5febf1751de4cef2863749f93e7.tar.xz freeipa-33aba6f35e43b5febf1751de4cef2863749f93e7.zip |
Use byte literals where appropriate
Reviewed-By: Petr Viktorin <pviktori@redhat.com>
Diffstat (limited to 'ipatests')
-rw-r--r-- | ipatests/data.py | 6 | ||||
-rw-r--r-- | ipatests/test_ipalib/test_parameters.py | 4 | ||||
-rw-r--r-- | ipatests/test_ipalib/test_rpc.py | 24 | ||||
-rw-r--r-- | ipatests/test_ipaserver/test_ldap.py | 4 | ||||
-rw-r--r-- | ipatests/test_xmlrpc/test_baseldap_plugin.py | 4 |
5 files changed, 21 insertions, 21 deletions
diff --git a/ipatests/data.py b/ipatests/data.py index 5abfffcfd..7fe2002c6 100644 --- a/ipatests/data.py +++ b/ipatests/data.py @@ -25,12 +25,12 @@ import struct # A string that should have bytes 'x\00' through '\xff': -binary_bytes = ''.join(struct.pack('B', d) for d in range(256)) -assert '\x00' in binary_bytes and '\xff' in binary_bytes +binary_bytes = b''.join(struct.pack('B', d) for d in range(256)) +assert b'\x00' in binary_bytes and b'\xff' in binary_bytes assert type(binary_bytes) is str and len(binary_bytes) == 256 # A UTF-8 encoded str: -utf8_bytes = '\xd0\x9f\xd0\xb0\xd0\xb2\xd0\xb5\xd0\xbb' +utf8_bytes = b'\xd0\x9f\xd0\xb0\xd0\xb2\xd0\xb5\xd0\xbb' # The same UTF-8 data decoded (a unicode instance): unicode_str = u'\u041f\u0430\u0432\u0435\u043b' diff --git a/ipatests/test_ipalib/test_parameters.py b/ipatests/test_ipalib/test_parameters.py index 6b8fc1d94..929289258 100644 --- a/ipatests/test_ipalib/test_parameters.py +++ b/ipatests/test_ipalib/test_parameters.py @@ -46,7 +46,7 @@ from ipalib import _ if six.PY3: unicode = str -NULLS = (None, '', u'', tuple(), []) +NULLS = (None, b'', u'', tuple(), []) class test_DefaultFrom(ClassChecker): """ @@ -1636,4 +1636,4 @@ class test_DateTime(ClassChecker): u'1991-31-12Z', u'1991-12-07T25:30:05Z', ): - raises(ConversionError, o.convert, value)
\ No newline at end of file + raises(ConversionError, o.convert, value) diff --git a/ipatests/test_ipalib/test_rpc.py b/ipatests/test_ipalib/test_rpc.py index 31ed73cd5..1d3f33add 100644 --- a/ipatests/test_ipalib/test_rpc.py +++ b/ipatests/test_ipalib/test_rpc.py @@ -67,10 +67,10 @@ def test_round_trip(): assert_equal(dump_n_load(unicode_str), unicode_str) assert_equal(dump_n_load(Binary(binary_bytes)).data, binary_bytes) assert isinstance(dump_n_load(Binary(binary_bytes)), Binary) - assert type(dump_n_load('hello')) is bytes + assert type(dump_n_load(b'hello')) is bytes assert type(dump_n_load(u'hello')) is bytes - assert_equal(dump_n_load(''), '') - assert_equal(dump_n_load(u''), '') + assert_equal(dump_n_load(b''), b'') + assert_equal(dump_n_load(u''), b'') assert dump_n_load(None) is None # Now we test our wrap and unwrap methods in combination with dumps, loads: @@ -81,9 +81,9 @@ def test_round_trip(): assert_equal(round_trip(utf8_bytes), utf8_bytes) assert_equal(round_trip(unicode_str), unicode_str) assert_equal(round_trip(binary_bytes), binary_bytes) - assert type(round_trip('hello')) is bytes + assert type(round_trip(b'hello')) is bytes assert type(round_trip(u'hello')) is unicode - assert_equal(round_trip(''), '') + assert_equal(round_trip(b''), b'') assert_equal(round_trip(u''), u'') assert round_trip(None) is None compound = [utf8_bytes, None, binary_bytes, (None, unicode_str), @@ -99,13 +99,13 @@ def test_xml_wrap(): f = rpc.xml_wrap assert f([], API_VERSION) == tuple() assert f({}, API_VERSION) == dict() - b = f('hello', API_VERSION) + b = f(b'hello', API_VERSION) assert isinstance(b, Binary) - assert b.data == 'hello' + assert b.data == b'hello' u = f(u'hello', API_VERSION) assert type(u) is unicode assert u == u'hello' - value = f([dict(one=False, two=u'hello'), None, 'hello'], API_VERSION) + value = f([dict(one=False, two=u'hello'), None, b'hello'], API_VERSION) def test_xml_unwrap(): @@ -120,8 +120,8 @@ def test_xml_unwrap(): assert value == utf8_bytes assert f(utf8_bytes) == unicode_str assert f(unicode_str) == unicode_str - value = f([True, Binary('hello'), dict(one=1, two=utf8_bytes, three=None)]) - assert value == (True, 'hello', dict(one=1, two=unicode_str, three=None)) + value = f([True, Binary(b'hello'), dict(one=1, two=utf8_bytes, three=None)]) + assert value == (True, b'hello', dict(one=1, two=unicode_str, three=None)) assert type(value[1]) is bytes assert type(value[2]['two']) is unicode @@ -134,7 +134,7 @@ def test_xml_dumps(): params = (binary_bytes, utf8_bytes, unicode_str, None) # Test serializing an RPC request: - data = f(params, API_VERSION, 'the_method') + data = f(params, API_VERSION, b'the_method') (p, m) = loads(data) assert_equal(m, u'the_method') assert type(p) is tuple @@ -165,7 +165,7 @@ def test_xml_loads(): wrapped = rpc.xml_wrap(params, API_VERSION) # Test un-serializing an RPC request: - data = dumps(wrapped, 'the_method', allow_none=True) + data = dumps(wrapped, b'the_method', allow_none=True) (p, m) = f(data) assert_equal(m, u'the_method') assert_equal(p, params) diff --git a/ipatests/test_ipaserver/test_ldap.py b/ipatests/test_ipaserver/test_ldap.py index c3a9717c5..47d37c9bf 100644 --- a/ipatests/test_ipaserver/test_ldap.py +++ b/ipatests/test_ipaserver/test_ldap.py @@ -306,7 +306,7 @@ class test_LDAPEntry(object): assert nice == [2, 3, u'5'] assert raw == ['3', '5', '2'] - raw = ['a', 'b'] + raw = [b'a', b'b'] e.raw['test'] = raw assert e['test'] is not nice assert e['test'] == [u'a', u'b'] @@ -314,7 +314,7 @@ class test_LDAPEntry(object): nice = 'not list' e['test'] = nice assert e['test'] is nice - assert e.raw['test'] == ['not list'] + assert e.raw['test'] == [b'not list'] e.raw['test'].append('second') assert e['test'] == ['not list', u'second'] diff --git a/ipatests/test_xmlrpc/test_baseldap_plugin.py b/ipatests/test_xmlrpc/test_baseldap_plugin.py index 6da56262b..477772c00 100644 --- a/ipatests/test_xmlrpc/test_baseldap_plugin.py +++ b/ipatests/test_xmlrpc/test_baseldap_plugin.py @@ -201,13 +201,13 @@ def test_entry_to_dict(): DN('cn=test'), textattr=[u'text'], dnattr=[DN('cn=test')], - binaryattr=['\xffabcd'], + binaryattr=[b'\xffabcd'], attributelevelrights=rights) the_dict = { u'dn': u'cn=test', u'textattr': [u'text'], u'dnattr': [u'cn=test'], - u'binaryattr': ['\xffabcd'], + u'binaryattr': [b'\xffabcd'], u'attributelevelrights': rights} assert_deepequal( baseldap.entry_to_dict(entry, all=True, raw=True), |