test_config_validator.test_missing_field()   A
last analyzed

Complexity

Conditions 2

Size

Total Lines 5
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 5
nop 0
dl 0
loc 5
rs 10
c 0
b 0
f 0
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