(tmp_path)
| 1360 | |
| 1361 | |
| 1362 | def test_jsonlines_reading(tmp_path): |
| 1363 | class InputSchema(pw.Schema): |
| 1364 | a: int |
| 1365 | b: int |
| 1366 | c: int | None |
| 1367 | |
| 1368 | path = tmp_path / "input.jsonlines" |
| 1369 | generate_jsonlines(path) |
| 1370 | input = pw.io.jsonlines.read(path, schema=InputSchema, mode="static") |
| 1371 | result = input.with_columns( |
| 1372 | b=pw.fill_error(pw.this.b, 0), c=pw.fill_error(pw.this.c, 0) |
| 1373 | ) |
| 1374 | expected = T( |
| 1375 | """ |
| 1376 | a | b | c |
| 1377 | 1 | 2 | 3 |
| 1378 | 2 | 0 | 3 |
| 1379 | 1 | 3 | 0 |
| 1380 | 6 | 0 | 0 |
| 1381 | 7 | 1 | |
| 1382 | """ |
| 1383 | ) |
| 1384 | expected_errors = T( |
| 1385 | """ |
| 1386 | message |
| 1387 | failed to create a field "b" with type int from json payload: "x" |
| 1388 | failed to create a field "b" with type int from json payload: "1" |
| 1389 | failed to create a field "c" with type int / None from json payload: "t" |
| 1390 | failed to create a field "c" with type int / None from json payload: "y" |
| 1391 | """, |
| 1392 | split_on_whitespace=False, |
| 1393 | ).select(message=pw.this.message.str.replace("/", "|")) |
| 1394 | # can't use | because it's a column sep |
| 1395 | |
| 1396 | assert_table_equality_wo_index( |
| 1397 | (result, pw.global_error_log().select(pw.this.message)), |
| 1398 | (expected, expected_errors), |
| 1399 | terminate_on_error=False, |
| 1400 | ) |
| 1401 | |
| 1402 | |
| 1403 | def test_jsonlines_reading_pk(tmp_path): |
nothing calls this directly
no test coverage detected