(self)
| 360 | |
| 361 | class 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") |
nothing calls this directly
no test coverage detected