|
| 1 | +from pathlib import Path |
1 | 2 | from typing import Callable, Dict, List |
2 | 3 |
|
3 | 4 | import pytest |
4 | | -import ulist as ul |
5 | 5 | from ulist.utils import check_test_result |
6 | 6 |
|
| 7 | +import ulist as ul |
| 8 | + |
| 9 | +here = Path(__file__).parent.resolve() |
| 10 | + |
7 | 11 |
|
8 | 12 | @pytest.mark.parametrize( |
9 | 13 | "test_method, args, kwargs, expected_value", |
10 | 14 | [ |
11 | 15 | (ul.read_csv, (), { |
12 | | - "path": "./test_csv/00_test_int.csv", |
13 | | - "schema": {"int32": "int32", "int64": "int64"} |
14 | | - }, { |
15 | | - "int32": [-2147483648, 2147483647, +2147483647], |
16 | | - "int64": [-9223372036854774808, |
17 | | - 9223372036854774807, |
18 | | - +9223372036854774807], |
19 | | - }), |
| 16 | + "path": str(here / "test_csv/00_test_int.csv"), |
| 17 | + "schema": {"int32": "int32", "int64": "int64"} |
| 18 | + }, { |
| 19 | + "int32": [-2147483648, 2147483647, +2147483647], |
| 20 | + "int64": [-9223372036854774808, |
| 21 | + 9223372036854774807, |
| 22 | + +9223372036854774807], |
| 23 | + }), |
20 | 24 | (ul.read_csv, (), { |
21 | | - "path": "./test_csv/01_test_float.csv", |
22 | | - "schema": {"float32": "float32", "float64": "float64"} |
23 | | - }, { |
24 | | - # Precision problem in float32 |
25 | | - "float32": [3.14159, 0.314, 0.314], |
26 | | - "float64": [3.14159, 31.4, 31.4] |
27 | | - }), |
| 25 | + "path": str(here / "test_csv/01_test_float.csv"), |
| 26 | + "schema": {"float32": "float32", "float64": "float64"} |
| 27 | + }, { |
| 28 | + # Precision problem in float32 |
| 29 | + "float32": [3.14159, 0.314, 0.314], |
| 30 | + "float64": [3.14159, 31.4, 31.4] |
| 31 | + }), |
28 | 32 | (ul.read_csv, (), { |
29 | | - "path": "./test_csv/02_test_bool.csv", |
30 | | - "schema": {"bool": "bool"} |
31 | | - }, { |
32 | | - "bool": [True, False, True, False] |
33 | | - }), |
| 33 | + "path": str(here / "test_csv/02_test_bool.csv"), |
| 34 | + "schema": {"bool": "bool"} |
| 35 | + }, { |
| 36 | + "bool": [True, False, True, False] |
| 37 | + }), |
34 | 38 | (ul.read_csv, (), { |
35 | | - "path": "./test_csv/03_test_string.csv", |
36 | | - "schema": {"string": "string"} |
37 | | - }, { |
38 | | - "string": ["String", 'Hello, "World"', None, "Long\nString"] |
39 | | - }), |
| 39 | + "path": str(here / "test_csv/03_test_string.csv"), |
| 40 | + "schema": {"string": "string"} |
| 41 | + }, { |
| 42 | + "string": ["String", 'Hello, "World"', None, "Long\nString"] |
| 43 | + }), |
40 | 44 | (ul.read_csv, (), { |
41 | | - "path": "./test_csv/04_test_nan.csv", |
42 | | - "schema": {"int": "int", |
43 | | - "float": "float", |
44 | | - "string": "string", |
45 | | - "bool": "bool"} |
46 | | - }, { |
47 | | - "int": [None, 2, 3, 4], |
48 | | - "float": [1.0, None, 3.0, 4.0], |
49 | | - "string": ["1", "2", None, "4"], |
50 | | - "bool": [True, False, True, None] |
51 | | - }), |
| 45 | + "path": str(here / "test_csv/04_test_nan.csv"), |
| 46 | + "schema": {"int": "int", |
| 47 | + "float": "float", |
| 48 | + "string": "string", |
| 49 | + "bool": "bool"} |
| 50 | + }, { |
| 51 | + "int": [None, 2, 3, 4], |
| 52 | + "float": [1.0, None, 3.0, 4.0], |
| 53 | + "string": ["1", "2", None, "4"], |
| 54 | + "bool": [True, False, True, None] |
| 55 | + }), |
52 | 56 | (ul.read_csv, (), { # schema.len() < field.len() |
53 | | - "path": "./test_csv/04_test_nan.csv", |
54 | | - "schema": {"int": "int", |
55 | | - "bool": "bool"} |
56 | | - }, { |
57 | | - "int": [None, 2, 3, 4], |
58 | | - "bool": [True, False, True, None] |
59 | | - }), |
| 57 | + "path": str(here / "test_csv/04_test_nan.csv"), |
| 58 | + "schema": {"int": "int", |
| 59 | + "bool": "bool"} |
| 60 | + }, { |
| 61 | + "int": [None, 2, 3, 4], |
| 62 | + "bool": [True, False, True, None] |
| 63 | + }), |
60 | 64 | (ul.read_csv, (), { # schema.len() > field.len() |
61 | | - "path": "./test_csv/02_test_bool.csv", |
| 65 | + "path": str(here / "test_csv/02_test_bool.csv"), |
62 | 66 | "schema": {"foo": "int", |
63 | 67 | "bar": "bool", |
64 | 68 | "bool": "bool"} |
65 | | - }, { |
66 | | - "foo": [], |
67 | | - "bar": [], |
68 | | - "bool": [True, False, True, False] |
69 | | - }) |
| 69 | + }, { |
| 70 | + "foo": [], |
| 71 | + "bar": [], |
| 72 | + "bool": [True, False, True, False] |
| 73 | + }) |
70 | 74 | ], |
71 | 75 | ) |
72 | 76 | def test_constructors( |
|
0 commit comments