test_config_validator   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 24
dl 0
loc 34
rs 10
c 0
b 0
f 0
wmc 8

4 Functions

Rating   Name   Duplication   Size   Complexity  
A test_missing_section() 0 4 2
A test_bad_field_type() 0 4 2
A test_missing_field() 0 5 2
A test_good_config() 0 6 2
1
from yfrake import config
2
from pathlib import Path
3
import pytest
4
5
6
configs_dir = Path(__file__).with_name('config_files')
7
8
9
def test_good_config():
10
    file = configs_dir.joinpath('good_config.ini')
11
    try:
12
        config.file = file
13
    except (AttributeError, KeyError, ValueError):
14
        pytest.fail('Good config raised an exception.')
15
16
17
def test_missing_section():
18
    file = configs_dir.joinpath('missing_section.ini')
19
    with pytest.raises(AttributeError):
20
        config.file = file
21
22
23
def test_missing_field():
24
    file = configs_dir.joinpath('missing_field.ini')
25
    print(file)
26
    with pytest.raises(KeyError):
27
        config.file = file
28
29
30
def test_bad_field_type():
31
    file = configs_dir.joinpath('bad_field_type.ini')
32
    with pytest.raises(ValueError):
33
        config.file = file
34