Skip to content

Commit 5e26697

Browse files
committed
xxx
1 parent 4ebdb11 commit 5e26697

File tree

1 file changed

+45
-23
lines changed

1 file changed

+45
-23
lines changed

tests/test_mig_shared_base.py

Lines changed: 45 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@
3333

3434
from tests.support import PY2, MigTestCase, testmain
3535

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
3739

3840
DUMMY_BYTECHARS = b'DEADBEEF'
3941
DUMMY_BYTESRAW = binascii.unhexlify('DEADBEEF') # 4 bytes
@@ -56,46 +58,66 @@ def test_encode_within_a_dict(self):
5658
def test_encode_within_a_list(self):
5759
output = force_default_fs_coding_rec(['foo', 'bar', 'baz'])
5860

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)
6066

6167
def test_encode_within_a_tuple(self):
6268
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'))
6372

64-
self.assertEqual(output, (b'foo', b'bar', b'baz'))
73+
self.assertEqual(output, truth)
6574

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'))
6680

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)
6982

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'))
7288

73-
self.assertEqual(output, 'foobar')
89+
self.assertEqual(output, truth)
7490

75-
def test_encode_within_a_dict(self):
76-
output = force_default_str_coding_rec({ 'key': 'value' })
7791

78-
self.assertEqual(output, { 'key': 'value' })
92+
class MigSharedBase__force_utf8(MigTestCase):
93+
"""Unit tests of mig.shared.base force_utf8()"""
7994

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')
8297

83-
self.assertEqual(output, ['foo', 'bar', 'baz'])
98+
self.assertEqual(output, truth)
8499

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')
87102

88-
self.assertEqual(output, ('foo', 'bar', 'baz'))
103+
self.assertEqual(output, truth)
89104

105+
def test_encode_unicode(self):
106+
output = force_utf8(u'foobar')
90107

91-
class MigSharedBase__force_utf8(MigTestCase):
92-
"""Unit tests of mig.shared.base force_utf8()"""
108+
self.assertEqual(output, truth)
93109

94-
def test_encode_a_string(self):
95-
output = force_utf8('foobar')
96110

97-
self.assertEqual(output, b'foobar')
111+
class MigSharedBase__force_unicode(MigTestCase):
112+
"""Unit tests of mig.shared.base force_unicode()"""
98113

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
99121

100122
if __name__ == '__main__':
101-
testmain()
123+
testmain(failfast=True)

0 commit comments

Comments
 (0)