MCPcopy
hub / github.com/scrapy/scrapy / test_csviter_defaults

Method test_csviter_defaults

tests/test_utils_iterators.py:362–378  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

360
361class TestUtilsCsv:
362 def test_csviter_defaults(self):
363 body = get_testdata("feeds", "feed-sample3.csv")
364 response = TextResponse(url="http://example.com/", body=body)
365 csv = csviter(response)
366
367 result = list(csv)
368 assert result == [
369 {"id": "1", "name": "alpha", "value": "foobar"},
370 {"id": "2", "name": "unicode", "value": "\xfan\xedc\xf3d\xe9\u203d"},
371 {"id": "3", "name": "multi", "value": "foo\nbar"},
372 {"id": "4", "name": "empty", "value": ""},
373 ]
374
375 # explicit type check cuz' we no like stinkin' autocasting! yarrr
376 for result_row in result:
377 assert all(isinstance(k, str) for k in result_row)
378 assert all(isinstance(v, str) for v in result_row.values())
379
380 def test_csviter_delimiter(self):
381 body = get_testdata("feeds", "feed-sample3.csv").replace(b",", b"\t")

Callers

nothing calls this directly

Calls 4

get_testdataFunction · 0.90
TextResponseClass · 0.90
csviterFunction · 0.90
valuesMethod · 0.80

Tested by

no test coverage detected