Skip to content

Commit 0858bee

Browse files
committed
Fix recursive items comparison
1 parent a50c760 commit 0858bee

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

scrapy_autounit/player.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,15 +78,20 @@ def _get_middlewares(self):
7878
continue
7979
return middlewares
8080

81+
def _item_to_dict(self, value):
82+
if not isinstance(value, Item):
83+
return value
84+
as_dict = dict(value)
85+
for key, val in as_dict.items():
86+
as_dict[key] = self._item_to_dict(val)
87+
return as_dict
88+
8189
def _compare(self, expected, found, message):
8290
x_label = "expected"
8391
y_label = "found"
8492

85-
if isinstance(expected, Item):
86-
expected = dict(expected)
87-
88-
if isinstance(found, Item):
89-
found = dict(found)
93+
expected = self._item_to_dict(expected)
94+
found = self._item_to_dict(found)
9095

9196
compare(
9297
expected=expected,

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
setuptools.setup(
88
name='scrapy-autounit',
9-
version='0.0.31',
9+
version='0.0.32',
1010
author='',
1111
author_email='',
1212
description='Automatic unit test generation for Scrapy.',

0 commit comments

Comments
 (0)