33
33
34
34
from tests .support import PY2 , MigTestCase , testmain
35
35
36
- from mig .shared .base import force_default_fs_coding_rec , force_default_str_coding_rec
36
+ from mig .shared .base import force_default_fs_coding_rec , force_default_str_coding_rec , force_utf8
37
37
38
38
DUMMY_BYTECHARS = b'DEADBEEF'
39
39
DUMMY_BYTESRAW = binascii .unhexlify ('DEADBEEF' ) # 4 bytes
@@ -46,22 +46,22 @@ class MigSharedBase__force_default_fs_coding_rec(MigTestCase):
46
46
def test_encode_a_string (self ):
47
47
output = force_default_fs_coding_rec ('foobar' )
48
48
49
- self .assertEqual (output , 'foobar' )
49
+ self .assertEqual (output , b 'foobar' )
50
50
51
51
def test_encode_within_a_dict (self ):
52
52
output = force_default_fs_coding_rec ({ 'key' : 'value' })
53
53
54
- self .assertEqual (output , { 'key' : 'value' })
54
+ self .assertEqual (output , { b 'key' : b 'value' })
55
55
56
56
def test_encode_within_a_list (self ):
57
57
output = force_default_fs_coding_rec (['foo' , 'bar' , 'baz' ])
58
58
59
- self .assertEqual (output , ['foo' , 'bar' , 'baz' ])
59
+ self .assertEqual (output , [b 'foo' , b 'bar' , b 'baz' ])
60
60
61
61
def test_encode_within_a_tuple (self ):
62
62
output = force_default_fs_coding_rec (('foo' , 'bar' , 'baz' ))
63
63
64
- self .assertEqual (output , ('foo' , 'bar' , 'baz' ))
64
+ self .assertEqual (output , (b 'foo' , b 'bar' , b 'baz' ))
65
65
66
66
67
67
class MigSharedBase__force_default_str_coding_rec (MigTestCase ):
@@ -88,5 +88,14 @@ def test_encode_within_a_tuple(self):
88
88
self .assertEqual (output , ('foo' , 'bar' , 'baz' ))
89
89
90
90
91
+ class MigSharedBase__force_utf8 (MigTestCase ):
92
+ """Unit tests of mig.shared.base force_utf8()"""
93
+
94
+ def test_encode_a_string (self ):
95
+ output = force_utf8 ('foobar' )
96
+
97
+ self .assertEqual (output , b'foobar' )
98
+
99
+
91
100
if __name__ == '__main__' :
92
101
testmain ()
0 commit comments