MCPcopy
hub / github.com/scrapy/scrapy / test_export_feed_export_fields

Method test_export_feed_export_fields

tests/test_feedexport.py:866–889  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

864
865 @coroutine_test
866 async def test_export_feed_export_fields(self):
867 # FEED_EXPORT_FIELDS option allows to order export fields
868 # and to select a subset of fields to export, both for Items and dicts.
869
870 for item_cls in [self.MyItem, dict]:
871 items = [
872 item_cls({"foo": "bar1", "egg": "spam1"}),
873 item_cls({"foo": "bar2", "egg": "spam2", "baz": "quux2"}),
874 ]
875
876 # export all columns
877 settings = {"FEED_EXPORT_FIELDS": "foo,baz,egg"}
878 rows = [
879 {"egg": "spam1", "foo": "bar1", "baz": ""},
880 {"egg": "spam2", "foo": "bar2", "baz": "quux2"},
881 ]
882 await self.assertExported(
883 items, ["foo", "baz", "egg"], rows, settings=settings
884 )
885
886 # export a subset of columns
887 settings = {"FEED_EXPORT_FIELDS": "egg,baz"}
888 rows = [{"egg": "spam1", "baz": ""}, {"egg": "spam2", "baz": "quux2"}]
889 await self.assertExported(items, ["egg", "baz"], rows, settings=settings)
890
891 @coroutine_test
892 async def test_export_encoding(self):

Callers

nothing calls this directly

Calls 1

assertExportedMethod · 0.80

Tested by

no test coverage detected