Skip to content

Commit

Permalink
Fix recursive items comparison
Browse files Browse the repository at this point in the history
  • Loading branch information
fcanobrash committed Jul 9, 2021
1 parent a50c760 commit 0858bee
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
15 changes: 10 additions & 5 deletions scrapy_autounit/player.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,20 @@ def _get_middlewares(self):
continue
return middlewares

def _item_to_dict(self, value):
if not isinstance(value, Item):
return value
as_dict = dict(value)
for key, val in as_dict.items():
as_dict[key] = self._item_to_dict(val)
return as_dict

def _compare(self, expected, found, message):
x_label = "expected"
y_label = "found"

if isinstance(expected, Item):
expected = dict(expected)

if isinstance(found, Item):
found = dict(found)
expected = self._item_to_dict(expected)
found = self._item_to_dict(found)

compare(
expected=expected,
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

setuptools.setup(
name='scrapy-autounit',
version='0.0.31',
version='0.0.32',
author='',
author_email='',
description='Automatic unit test generation for Scrapy.',
Expand Down

0 comments on commit 0858bee

Please sign in to comment.