show all the missing field when scrapes contract fails

This commit is contained in:
tpeng 2014-06-26 11:28:03 +02:00 committed by Adrián Chaves
parent eef1732374
commit a8621bbc29
1 changed files with 3 additions and 3 deletions

View File

@ -84,6 +84,6 @@ class ScrapesContract(Contract):
def post_process(self, output):
for x in output:
if isinstance(x, (BaseItem, dict)):
for arg in self.args:
if not arg in x:
raise ContractFail("'%s' field is missing" % arg)
missing = [arg for arg in self.args if arg not in x]
if missing:
raise ContractFail("'%s' field is missing" % " ".join(missing))