Skip to content

Commit e7a231c

Browse files
author
Fede A
committed
switch dict for OrderedDict for backward compatibility
1 parent fd30e4e commit e7a231c

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

tests/tests_v2.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
import unittest
4040
import struct
4141

42+
from collections import OrderedDict
4243
from io import BytesIO
4344

4445
# Prepare Python path to import javaobj
@@ -76,7 +77,7 @@ def load_from_instance(self):
7677
int_not_in_fields = struct.unpack('>i', BytesIO(raw_data[0].data).read(4))[0]
7778
custom_obj = raw_data[1]
7879
values = [int_not_in_fields, custom_obj]
79-
self.field_data = dict(zip(fields, values))
80+
self.field_data = OrderedDict(zip(fields, values))
8081
return True
8182

8283
return False
@@ -91,10 +92,10 @@ def load_from_instance(self):
9192
if self.classdesc and self.classdesc in self.field_data:
9293
fields = self.classdesc.fields_names
9394
values = self.field_data[self.classdesc].values()
94-
self.field_data = dict(zip(fields, values))
95+
self.field_data = OrderedDict(zip(fields, values))
9596
if self.classdesc.super_class and self.classdesc.super_class in self.annotations:
9697
super_class = self.annotations[self.classdesc.super_class][0]
97-
self.annotations = dict(
98+
self.annotations = OrderedDict(
9899
zip(super_class.fields_names, super_class.field_data))
99100
return True
100101

@@ -545,7 +546,7 @@ def test_writeObject(self):
545546
parent_data = pobj.field_data
546547
child_data = parent_data['custom_obj'].field_data
547548
super_data = parent_data['custom_obj'].annotations
548-
expected = {
549+
expected = OrderedDict({
549550
'int_not_in_fields': 0,
550551
'custom_obj': {
551552
'field_data': {
@@ -558,7 +559,7 @@ def test_writeObject(self):
558559
'seed': 25214903879
559560
}
560561
}
561-
}
562+
})
562563

563564
self.assertEqual(expected['int_not_in_fields'], parent_data['int_not_in_fields'])
564565
self.assertEqual(expected['custom_obj']['field_data'], child_data)

0 commit comments

Comments
 (0)