(tmp_path)
| 65 | |
| 66 | @pytest.fixture |
| 67 | def generate_sample_data_csv(tmp_path): |
| 68 | def _generate(id_type: Literal["int", "str"] = "int"): |
| 69 | # Generate a dummy dataset with SAMPLE_DATA_NUM_ROWS rows and columns [ID_COL, "col1"] |
| 70 | ids = ( |
| 71 | [f"id_{i}" for i in range(SAMPLE_DATA_NUM_ROWS)] |
| 72 | if id_type == "str" |
| 73 | else list(range(SAMPLE_DATA_NUM_ROWS)) |
| 74 | ) |
| 75 | |
| 76 | data = [{ID_COL: id_val, "col1": random.random()} for id_val in ids] |
| 77 | |
| 78 | f_path = os.path.join(tmp_path, "sample_data.csv") |
| 79 | with open(f_path, mode="w", newline="") as file: |
| 80 | writer = csv.DictWriter(file, fieldnames=data[0].keys()) |
| 81 | writer.writeheader() |
| 82 | writer.writerows(data) |
| 83 | return f_path |
| 84 | |
| 85 | return _generate |
| 86 | |
| 87 | |
| 88 | @pytest.fixture |
no outgoing calls
no test coverage detected
searching dependent graphs…