Passed
Push — master ( 8b2ed0...4823d2 )
by Daniel
03:53
created

test_pset_io.test_SetWriter()   B

Complexity

Conditions 6

Size

Total Lines 16
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 11
dl 0
loc 16
rs 8.6666
c 0
b 0
f 0
cc 6
nop 2
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