Skip to content

Commit c89bc3c

Browse files
committed
fix failing tests in py 3.5
1 parent c81a425 commit c89bc3c

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

optimizely/project_config.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
# limitations under the License.
1313

1414
import json
15+
from collections import OrderedDict
1516

1617
from . import entities
1718
from . import exceptions
@@ -186,7 +187,10 @@ def _generate_key_map(entity_list, key, entity_class):
186187
Map mapping key to entity object.
187188
"""
188189

189-
key_map = {}
190+
# using ordered dict here to preserve insertion order of entities
191+
# OrderedDict() is needed for Py versions 3.5 and less to work.
192+
# Insertion order has been made default in dicts since Py 3.6
193+
key_map = OrderedDict()
190194
for obj in entity_list:
191195
key_map[obj[key]] = entity_class(**obj)
192196

@@ -218,6 +222,7 @@ def get_rollout_experiments_map(self, rollout):
218222
Returns:
219223
Mapped rollout experiments.
220224
"""
225+
221226
rollout_experiments_id_map = self._generate_key_map(rollout.experiments, 'id', entities.Experiment)
222227
rollout_experiments = [exper for exper in rollout_experiments_id_map.values()]
223228

0 commit comments

Comments
 (0)