Skip to content

Commit a9c079a

Browse files
author
Vignesh Raja
committed
Fix assertItemsEqual attribute error with Python 3
Summary: Fix assertItemsEqual attribute error with Python 3 Test Plan: Unit Reviewers: matthew.auerbach, jon Reviewed By: jon JIRA Issues: DEV-411 Differential Revision: https://phabricator.optimizely.com/D9714
1 parent b968667 commit a9c079a

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

tests/test_objects.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,11 @@ def test_list_equality(self):
6161
test_condition_list_2 = [objects.AudienceCondition('Weather', options)]
6262
# since __hash__ is set to None, collections.Counter comparison using memory addresses shouldn't be performed and
6363
# __eq__ should be called instead. Refer to: https://docs.python.org/2/reference/datamodel.html#object.__hash__
64-
self.assertItemsEqual(test_condition_list_1, test_condition_list_2)
65-
64+
try:
65+
self.assertItemsEqual(test_condition_list_1, test_condition_list_2)
66+
except AttributeError:
67+
# for Python 3.2+
68+
self.assertCountEqual(test_condition_list_1, test_condition_list_2)
6669

6770
class TestVisitorSet(unittest.TestCase):
6871
"""Tests for the optimizely_platform.objects.VisitorSet class."""

0 commit comments

Comments
 (0)