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 , force_utf8
36
+ from mig .shared .base import force_default_fs_coding_rec , \
37
+ force_default_fs_coding , force_default_str_coding_rec , \
38
+ force_default_str_coding , force_utf8 , force_unicode
37
39
38
40
DUMMY_BYTECHARS = b'DEADBEEF'
39
41
DUMMY_BYTESRAW = binascii .unhexlify ('DEADBEEF' ) # 4 bytes
@@ -56,46 +58,66 @@ def test_encode_within_a_dict(self):
56
58
def test_encode_within_a_list (self ):
57
59
output = force_default_fs_coding_rec (['foo' , 'bar' , 'baz' ])
58
60
59
- self .assertEqual (output , [b'foo' , b'bar' , b'baz' ])
61
+ truth = [force_default_str_coding ('foo' ),
62
+ force_default_str_coding ('bar' ),
63
+ force_default_str_coding ('baz' )]
64
+
65
+ self .assertEqual (output , truth )
60
66
61
67
def test_encode_within_a_tuple (self ):
62
68
output = force_default_fs_coding_rec (('foo' , 'bar' , 'baz' ))
69
+ truth = (force_default_str_coding ('foo' ),
70
+ force_default_str_coding ('bar' ),
71
+ force_default_str_coding ('baz' ))
63
72
64
- self .assertEqual (output , ( b'foo' , b'bar' , b'baz' ) )
73
+ self .assertEqual (output , truth )
65
74
75
+ def test_encode_within_a_tuple_bytes (self ):
76
+ output = force_default_fs_coding_rec (('foo' , 'bar' , 'baz' ))
77
+ truth = (force_default_str_coding ('foo' ),
78
+ force_default_str_coding ('bar' ),
79
+ force_default_str_coding ('baz' ))
66
80
67
- class MigSharedBase__force_default_str_coding_rec (MigTestCase ):
68
- """Unit tests of mig.shared.base force_default_str_coding_rec()"""
81
+ self .assertEqual (output , truth )
69
82
70
- def test_encode_a_string (self ):
71
- output = force_default_str_coding_rec ('foobar' )
83
+ def test_encode_within_a_tuple_unicode (self ):
84
+ output = force_default_fs_coding_rec (('foo' , 'bar' , 'baz' ))
85
+ truth = (force_default_str_coding ('foo' ),
86
+ force_default_str_coding ('bar' ),
87
+ force_default_str_coding ('baz' ))
72
88
73
- self .assertEqual (output , 'foobar' )
89
+ self .assertEqual (output , truth )
74
90
75
- def test_encode_within_a_dict (self ):
76
- output = force_default_str_coding_rec ({ 'key' : 'value' })
77
91
78
- self .assertEqual (output , { 'key' : 'value' })
92
+ class MigSharedBase__force_utf8 (MigTestCase ):
93
+ """Unit tests of mig.shared.base force_utf8()"""
79
94
80
- def test_encode_within_a_list (self ):
81
- output = force_default_str_coding_rec ([ 'foo' , 'bar' , 'baz' ] )
95
+ def test_encode_string (self ):
96
+ output = force_utf8 ( 'foobar' )
82
97
83
- self .assertEqual (output , [ 'foo' , 'bar' , 'baz' ] )
98
+ self .assertEqual (output , truth )
84
99
85
- def test_encode_within_a_tuple (self ):
86
- output = force_default_str_coding_rec (( 'foo' , 'bar' , 'baz' ) )
100
+ def test_encode_bytes (self ):
101
+ output = force_utf8 ( b'foobar' )
87
102
88
- self .assertEqual (output , ( 'foo' , 'bar' , 'baz' ) )
103
+ self .assertEqual (output , truth )
89
104
105
+ def test_encode_unicode (self ):
106
+ output = force_utf8 (u'foobar' )
90
107
91
- class MigSharedBase__force_utf8 (MigTestCase ):
92
- """Unit tests of mig.shared.base force_utf8()"""
108
+ self .assertEqual (output , truth )
93
109
94
- def test_encode_a_string (self ):
95
- output = force_utf8 ('foobar' )
96
110
97
- self .assertEqual (output , b'foobar' )
111
+ class MigSharedBase__force_unicode (MigTestCase ):
112
+ """Unit tests of mig.shared.base force_unicode()"""
98
113
114
+ def test_encode_a_string (self ):
115
+ # input_vals = (b'foobar', u'foobar')
116
+ # truth = u'foobar'
117
+ # for val in input_vals:
118
+ # output = force_unicode(val)
119
+ # self.assertEqual(output, truth)
120
+ pass
99
121
100
122
if __name__ == '__main__' :
101
- testmain ()
123
+ testmain (failfast = True )
0 commit comments