Test saving data to JSON file.
(self, json_format, temp_dir, sample_data_list)
| 126 | json_format.load(filepath) |
| 127 | |
| 128 | def test_save_json(self, json_format, temp_dir, sample_data_list): |
| 129 | """Test saving data to JSON file.""" |
| 130 | filepath = os.path.join(temp_dir, "output.json") |
| 131 | json_format.save(sample_data_list, filepath) |
| 132 | |
| 133 | assert os.path.exists(filepath) |
| 134 | with open(filepath, "r", encoding="utf-8") as f: |
| 135 | loaded = json.load(f) |
| 136 | assert len(loaded) == len(sample_data_list) |
| 137 | |
| 138 | def test_save_json_with_indent(self, json_format, temp_dir, sample_data_list): |
| 139 | """Test saving JSON with custom indent.""" |