Skip to content

Commit

Permalink
100% coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
piotrmaslanka committed May 26, 2021
1 parent a04f513 commit e0458da
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
2 changes: 1 addition & 1 deletion minijson.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ cpdef object loads_object(bytes data, object obj_class):
"""
Load a dict from a bytestream, unserialize it and use it as a kwargs to instantiate
an object of given class
:param data: data to unserialized
:param obj_class: class to instantiate
:return: instance of obj_class
Expand Down
13 changes: 5 additions & 8 deletions tests/test_minijson.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,10 @@ def test_booleans(self):
'test2': False})

def test_string(self):
a = 'test'
b = 't'*128
c = 't'*65535
d = 't'*128342
self.assertSameAfterDumpsAndLoads(a)
self.assertSameAfterDumpsAndLoads(b)
self.assertSameAfterDumpsAndLoads(c)
self.assertSameAfterDumpsAndLoads(d)
self.assertSameAfterDumpsAndLoads('test')
self.assertSameAfterDumpsAndLoads('t'*128)
self.assertSameAfterDumpsAndLoads('t'*65535)
self.assertSameAfterDumpsAndLoads('t'*65540)

def test_lists(self):
a = [None]*4
Expand Down Expand Up @@ -121,3 +117,4 @@ def __init__(self, a):
c = loads_object(b, Test)
self.assertEqual(a.a, c.a)
self.assertIsInstance(c, Test)
self.assertRaises(DecodingError, lambda: loads_object(b'\x07\x00', Test))

0 comments on commit e0458da

Please sign in to comment.