MCPcopy
hub / github.com/scrapy/scrapy / assertExportedMultiple

Method assertExportedMultiple

tests/test_feedexport.py:392–415  ·  view source on GitHub ↗
(
        self,
        items: Iterable[Any],
        rows: Iterable[dict[str, Any]],
        settings: dict[str, Any] | None = None,
    )

Source from the content-addressed store, hash-verified

390 assert rows == got_rows
391
392 async def assertExportedMultiple(
393 self,
394 items: Iterable[Any],
395 rows: Iterable[dict[str, Any]],
396 settings: dict[str, Any] | None = None,
397 ) -> None:
398 settings = settings or {}
399 settings.update(
400 {
401 "FEEDS": {
402 self._random_temp_filename(): {"format": "xml"},
403 self._random_temp_filename(): {"format": "json"},
404 },
405 }
406 )
407 data = await self.exported_data(items, settings)
408 rows = [{k: v for k, v in row.items() if v} for row in rows]
409 # XML
410 root = lxml.etree.fromstring(data["xml"])
411 xml_rows = [{e.tag: e.text for e in it} for it in root.findall("item")]
412 assert rows == xml_rows
413 # JSON
414 json_rows = json.loads(to_unicode(data["json"]))
415 assert rows == json_rows
416
417 async def assertExportedPickle(
418 self,

Callers

nothing calls this directly

Calls 5

to_unicodeFunction · 0.90
_random_temp_filenameMethod · 0.80
exported_dataMethod · 0.80
itemsMethod · 0.80
updateMethod · 0.45

Tested by

no test coverage detected