conftest   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 7
eloc 27
dl 0
loc 36
rs 10
c 0
b 0
f 0

3 Functions

Rating   Name   Duplication   Size   Complexity  
A data_dir() 0 3 1
A reference_data() 0 14 4
A ccdc_enabled() 0 8 2
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
17
        return True
18
    except Exception:
19
        return False
20
21
22
@pytest.fixture(scope="session", autouse=True)
23
def reference_data(data_dir):
24
    """Data fixture of amd.PeriodicSet objects to use in tests."""
25
26
    filenames = ["cubic", "T2_experimental", "CSD_families"]
27
    refs = {}
28
    for name in filenames:
29
        path = str(data_dir / f"{name}.pkl")
30
        with open(path, "rb") as f:
31
            data = pickle.load(f)
32
        if not data:
33
            raise ValueError(f"Data not found in path {path}")
34
        refs[name] = data
35
    return refs
36