| Total Complexity | 8 |
| Total Lines | 34 |
| Duplicated Lines | 0 % |
| Changes | 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 |