8
8
9
9
@pytest .fixture ()
10
10
def our_cwd_setup (request ):
11
+ """Change cwd to test_cwd dir. Revert to original dir on teardown. """
12
+
11
13
bkp = os .getcwd ()
14
+
12
15
def our_cwd_teardown ():
13
16
os .chdir (bkp )
17
+
14
18
request .addfinalizer (our_cwd_teardown )
15
19
os .chdir (MYCWD )
16
20
17
21
18
-
19
22
@pytest .yield_fixture
20
23
def os_environ ():
21
- from kcli import conf
22
24
"""Backups env var from os.environ and restores it at teardown. """
25
+
26
+ from kcli import conf
27
+
23
28
backup_flag = False
24
29
if conf .ENV_VAR_NAME in os .environ :
25
30
backup_flag = True
@@ -31,28 +36,6 @@ def os_environ():
31
36
32
37
def test_get_config_dir (our_cwd_setup ):
33
38
from kcli import conf
34
- file = conf .load_config_file ()
35
- assert os .path .abspath (file .get ("DEFAULTS" , "KHALEESI_DIR" )) == \
36
- os .path .abspath (MYCWD )
37
-
38
- # # Negative - Missing input
39
- # with pytest.raises(ValueError) as exc:
40
- # core.get_config_dir(fake_config_cli(config_dir=None))
41
- # assert "Missing path" in str(exc.value)
42
- #
43
- # # Negative - Bad path
44
- # with pytest.raises(ValueError) as exc:
45
- # core.get_config_dir(fake_config_cli(config_dir="/fake/path"))
46
- # assert "Bad path" in str(exc.value)
47
- # assert "/fake/path" in str(exc.value)
48
- #
49
- # # verify CLI
50
- # assert core.get_config_dir(
51
- # fake_config_cli(config_dir=SETTINGS_DIR)) == SETTINGS_DIR
52
-
53
- # Verify ENV
54
-
55
- # # Verify CLI over ENV
56
- # os.environ["KHALEESI_SETTINGS"] = "/fake/env/path"
57
- # assert core.get_config_dir(
58
- # fake_config_cli(config_dir=SETTINGS_DIR)) == SETTINGS_DIR
39
+ conf_file = conf .load_config_file ()
40
+ assert os .path .abspath (conf_file .get ("DEFAULTS" , "KHALEESI_DIR" )) == \
41
+ os .path .abspath (MYCWD )
0 commit comments