Passed
Push — master ( 9e2dce...7c2d4e )
by Daniel
03:55
created

conftest.root_dir()   A

Complexity

Conditions 1

Size

Total Lines 3
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nop 0
1
import os
2
import pickle
3
import pytest
4
import pathlib
5
6
7
@pytest.fixture(scope='session', autouse=True)
8
def data_dir():
9
    return pathlib.Path(__file__).absolute().parent / 'data'
10
11
12
@pytest.fixture(scope='session', autouse=True)
13
def ccdc_enabled():
14
    try:
15
        import ccdc
16
        return True
17
    except Exception:
18
        return False
19
20
21
@pytest.fixture(scope='session', autouse=True)
22
def reference_data(data_dir):
23
    """Data fixture of amd.PeriodicSet objects to use in tests."""
24
25
    filenames = ['cubic', 'T2_experimental', 'CSD_families']
26
    refs = {}
27
    for name in filenames:
28
        path = str(data_dir / f'{name}.pkl')
29
        with open(path, 'rb') as f:
30
            data = pickle.load(f)
31
            if not data:
32
                raise ValueError(f'Data not found in path {path}')
33
            refs[name] = data
34
    return refs
35