Total Complexity | 10 |
Total Lines | 32 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | import os |
||
2 | import pytest |
||
3 | import amd |
||
4 | |||
5 | |||
6 | def test_SetReader(root_dir, reference_data): |
||
7 | structs = reference_data['CSD_families'] |
||
8 | |||
9 | for dataset, structs in reference_data.items(): |
||
10 | path = os.path.join(root_dir, rf'{dataset}.hdf5') |
||
11 | for s, s_ in zip(amd.SetReader(path), structs): |
||
12 | if not s == s_: |
||
13 | pytest.fail(f'On structure {s.name} SetReader disagrees with reference') |
||
14 | |||
15 | |||
16 | def test_SetWriter(root_dir, reference_data): |
||
17 | |||
18 | for name in reference_data: |
||
19 | refs = reference_data[name] |
||
20 | |||
21 | path = os.path.join(root_dir, rf'{name}_TEMP.hdf5') |
||
22 | |||
23 | with amd.SetWriter(path) as writer: |
||
24 | writer.iwrite(refs) |
||
25 | |||
26 | with amd.SetReader(path) as reader_: |
||
27 | for s, s_ in zip(refs, reader_): |
||
28 | if not s == s_: |
||
29 | pytest.fail(f'Structure {s_.name} written with SetWriter disagrees with reference') |
||
30 | |||
31 | os.remove(path) |
||
32 |