| 9 | |
| 10 | |
| 11 | class TestFromFile: |
| 12 | def test_from_all(self): |
| 13 | assert isinstance(box_from_file(Path(test_root, "data", "json_file.json")), Box) |
| 14 | assert isinstance(box_from_file(Path(test_root, "data", "toml_file.tml")), Box) |
| 15 | assert isinstance(box_from_file(Path(test_root, "data", "yaml_file.yaml")), Box) |
| 16 | assert isinstance(box_from_file(Path(test_root, "data", "json_file.json"), file_type="json"), Box) |
| 17 | assert isinstance(box_from_file(Path(test_root, "data", "toml_file.tml"), file_type="toml"), Box) |
| 18 | assert isinstance(box_from_file(Path(test_root, "data", "yaml_file.yaml"), file_type="yaml"), Box) |
| 19 | assert isinstance(box_from_file(Path(test_root, "data", "json_list.json")), BoxList) |
| 20 | assert isinstance(box_from_file(Path(test_root, "data", "yaml_list.yaml")), BoxList) |
| 21 | assert isinstance(box_from_file(Path(test_root, "data", "msgpack_file.msgpack")), Box) |
| 22 | assert isinstance(box_from_file(Path(test_root, "data", "msgpack_list.msgpack")), BoxList) |
| 23 | assert isinstance(box_from_file(Path(test_root, "data", "csv_file.csv")), BoxList) |
| 24 | |
| 25 | def test_bad_file(self): |
| 26 | with pytest.raises(BoxError): |
| 27 | box_from_file(Path(test_root, "data", "bad_file.txt"), file_type="json") |
| 28 | with pytest.raises(BoxError): |
| 29 | box_from_file(Path(test_root, "data", "bad_file.txt"), file_type="toml") |
| 30 | with pytest.raises(BoxError): |
| 31 | box_from_file(Path(test_root, "data", "bad_file.txt"), file_type="yaml") |
| 32 | with pytest.raises(BoxError): |
| 33 | box_from_file(Path(test_root, "data", "bad_file.txt"), file_type="msgpack") |
| 34 | with pytest.raises(BoxError): |
| 35 | box_from_file(Path(test_root, "data", "bad_file.txt"), file_type="unknown") |
| 36 | with pytest.raises(BoxError): |
| 37 | box_from_file(Path(test_root, "data", "bad_file.txt")) |
| 38 | with pytest.raises(BoxError): |
| 39 | box_from_file("does not exist") |
| 40 | |
| 41 | def test_from_string_all(self): |
| 42 | with open(Path(test_root, "data", "json_file.json"), "r") as f: |
| 43 | box_from_string(f.read()) |
| 44 | |
| 45 | with open(Path(test_root, "data", "toml_file.tml"), "r") as f: |
| 46 | box_from_string(f.read(), string_type="toml") |
| 47 | |
| 48 | with open(Path(test_root, "data", "yaml_file.yaml"), "r") as f: |
| 49 | box_from_string(f.read(), string_type="yaml") |
nothing calls this directly
no outgoing calls
no test coverage detected