11
11
from vcspull .config import expand_dir , extract_repos
12
12
13
13
from .fixtures import example as fixtures
14
- from .helpers import EnvironmentVarGuard , write_config
14
+ from .helpers import EnvironmentVarGuard , import_raw , load_raw , write_config
15
15
16
16
17
17
@pytest .fixture (scope = "function" )
@@ -30,9 +30,8 @@ def json_config(config_path: pathlib.Path):
30
30
31
31
def test_dict_equals_yaml ():
32
32
# Verify that example YAML is returning expected dict format.
33
- config = kaptan .Kaptan (handler = "yaml" ).import_config (
34
- textwrap .dedent (
35
- """\
33
+ config = import_raw (
34
+ """\
36
35
/home/me/myproject/study/:
37
36
linux: git+git://git.kernel.org/linux/torvalds/linux.git
38
37
freebsd: git+https://github.com/freebsd/freebsd.git
@@ -52,8 +51,8 @@ def test_dict_equals_yaml():
52
51
url: [email protected] :tony/tmux-config.git
53
52
shell_command_after:
54
53
- ln -sf /home/me/.tmux/.tmux.conf /home/me/.tmux.conf
55
- """
56
- )
54
+ """ ,
55
+ format = "yaml" ,
57
56
)
58
57
assert fixtures .config_dict == config .export ("dict" )
59
58
@@ -121,11 +120,8 @@ def test_expand_shell_command_after():
121
120
122
121
def test_expandenv_and_homevars ():
123
122
# Assure ~ tildes and environment template vars expand.
124
- config1 = (
125
- kaptan .Kaptan (handler = "yaml" )
126
- .import_config (
127
- textwrap .dedent (
128
- """\
123
+ config1 = load_raw (
124
+ """\
129
125
'~/study/':
130
126
sphinx: hg+file://{hg_repo_path}
131
127
docutils: svn+file://{svn_repo_path}
@@ -140,16 +136,11 @@ def test_expandenv_and_homevars():
140
136
url: git+file://{git_repo_path}
141
137
.tmux:
142
138
url: git+file://{git_repo_path}
143
- """
144
- )
145
- )
146
- .export ("dict" )
139
+ """ ,
140
+ format = "yaml" ,
147
141
)
148
- config2 = (
149
- kaptan .Kaptan (handler = "json" )
150
- .import_config (
151
- textwrap .dedent (
152
- """\
142
+ config2 = load_raw (
143
+ """\
153
144
{
154
145
"~/study/": {
155
146
"sphinx": "hg+file://${hg_repo_path}",
@@ -165,10 +156,8 @@ def test_expandenv_and_homevars():
165
156
}
166
157
}
167
158
}
168
- """
169
- )
170
- )
171
- .export ("dict" )
159
+ """ ,
160
+ format = "json" ,
172
161
)
173
162
174
163
config1_expanded = extract_repos (config1 )
@@ -191,7 +180,7 @@ def test_find_config_files(tmp_path: pathlib.Path):
191
180
pull_config .touch ()
192
181
with EnvironmentVarGuard () as env :
193
182
env .set ("HOME" , str (tmp_path ))
194
- os . environ . get ( "HOME" ) == str ( tmp_path )
183
+ assert pathlib . Path . home ( ) == tmp_path
195
184
expectedIn = str (tmp_path / ".vcspull.yaml" )
196
185
results = config .find_home_config_files ()
197
186
@@ -206,7 +195,7 @@ def test_multiple_config_files_raises_exception(tmp_path: pathlib.Path):
206
195
with EnvironmentVarGuard () as env :
207
196
with pytest .raises (exc .MultipleConfigWarning ):
208
197
env .set ("HOME" , str (tmp_path ))
209
- os . environ . get ( "HOME" ) == str ( tmp_path )
198
+ assert pathlib . Path . home ( ) == tmp_path
210
199
211
200
config .find_home_config_files ()
212
201
@@ -370,8 +359,7 @@ def test_find_config_include_home_config_files(
370
359
371
360
def test_merge_nested_dict (tmp_path : pathlib .Path , config_path : pathlib .Path ):
372
361
config1 = write_config (
373
- config_path = config_path ,
374
- filename = "repoduplicate1.yaml" ,
362
+ config_path = config_path / "repoduplicate1.yaml" ,
375
363
content = textwrap .dedent (
376
364
"""\
377
365
/path/to/test/:
@@ -383,8 +371,7 @@ def test_merge_nested_dict(tmp_path: pathlib.Path, config_path: pathlib.Path):
383
371
),
384
372
)
385
373
config2 = write_config (
386
- config_path = config_path ,
387
- filename = "repoduplicate2.yaml" ,
374
+ config_path = config_path / "repoduplicate2.yaml" ,
388
375
content = textwrap .dedent (
389
376
"""\
390
377
/path/to/test/:
0 commit comments