1+ from typing import Any
12import re
23
34import pytest
@@ -15,27 +16,27 @@ def test_replace_placeholders():
1516 'server' : {'name' : 'example.com' , 'url' : 'https://{server.name}' },
1617 'paths' : {
1718 'config_dir' : '/etc/myapp' ,
18- 'tmp' : {'tmp_base_path ' : '/tmp/myapp' },
19- 'full_tmp_path' : '{paths.tmp.tmp_base_path }/session' ,
19+ 'tmp' : {'tmp_base_dir ' : '/tmp/myapp' },
20+ 'full_tmp_path' : '{paths.tmp.tmp_base_dir }/session' ,
2021 },
2122 'logging' : {
2223 'log_dir' : '{paths.config_dir}/logs' ,
23- 'tmp_base_path ' : '/var/tmp' ,
24+ 'tmp_base_dir ' : '/var/tmp' ,
2425 # Should resolve within this section if key exists:
25- 'temp_dir' : '{tmp_base_path }' ,
26+ 'temp_dir' : '{tmp_base_dir }' ,
2627 },
2728 }
2829
2930 expected = {
3031 'server' : {'name' : 'example.com' , 'url' : 'https://example.com' },
3132 'paths' : {
3233 'config_dir' : '/etc/myapp' ,
33- 'tmp' : {'tmp_base_path ' : '/tmp/myapp' },
34+ 'tmp' : {'tmp_base_dir ' : '/tmp/myapp' },
3435 'full_tmp_path' : '/tmp/myapp/session' ,
3536 },
3637 'logging' : {
3738 'log_dir' : '/etc/myapp/logs' ,
38- 'tmp_base_path ' : '/var/tmp' ,
39+ 'tmp_base_dir ' : '/var/tmp' ,
3940 'temp_dir' : '/var/tmp' ,
4041 },
4142 }
@@ -69,7 +70,7 @@ def test_unresolved_key_in_config():
6970 'server' : {'name' : 'example.com' , 'url' : 'https://{server.name}' },
7071 'paths' : {
7172 'config_dir' : '/etc/myapp' ,
72- 'tmp' : {'tmp_base_path ' : '/tmp/myapp' },
73+ 'tmp' : {'tmp_base_dir ' : '/tmp/myapp' },
7374 # 'session' is missing in this section
7475 'full_tmp_path' : '{paths.tmp.session}/session' ,
7576 },
@@ -148,18 +149,18 @@ def test_chained_placeholder_resolution():
148149 data = {
149150 'paths' : {
150151 'tmp' : {
151- 'tmp_base_path ' : '/tmp/docbuild' ,
152- 'tmp_path ' : '{tmp_base_path }/doc-example-com' ,
153- 'tmp_deliverable_path ' : '{tmp_path }/deliverable/' ,
152+ 'tmp_base_dir ' : '/tmp/docbuild' ,
153+ 'tmp_dir ' : '{tmp_base_dir }/doc-example-com' ,
154+ 'tmp_deliverable_dir ' : '{tmp_dir }/deliverable/' ,
154155 },
155156 },
156157 }
157158
158- result = replace_placeholders (data )
159+ result : dict [ str , Any ] = replace_placeholders (data )
159160 tmp = result ['paths' ]['tmp' ]
160- assert tmp ['tmp_base_path ' ] == '/tmp/docbuild'
161- assert tmp ['tmp_path ' ] == '/tmp/docbuild/doc-example-com'
162- assert tmp ['tmp_deliverable_path ' ] == '/tmp/docbuild/doc-example-com/deliverable/'
161+ assert tmp ['tmp_base_dir ' ] == '/tmp/docbuild'
162+ assert tmp ['tmp_dir ' ] == '/tmp/docbuild/doc-example-com'
163+ assert tmp ['tmp_deliverable_dir ' ] == '/tmp/docbuild/doc-example-com/deliverable/'
163164
164165
165166def test_too_many_nested_placeholder_expansions ():
@@ -178,12 +179,12 @@ def test_too_many_nested_placeholder_expansions():
178179def test_chained_cross_section_placeholders ():
179180 config = {
180181 'build' : {
181- 'output' : '{paths.tmp_deliverable_path }' ,
182+ 'output' : '{paths.tmp_deliverable_dir }' ,
182183 },
183184 'paths' : {
184- 'tmp_base_path ' : '/tmp/docbuild' ,
185- 'tmp_path ' : '{tmp_base_path }/doc-example-com' ,
186- 'tmp_deliverable_path ' : '{paths.tmp_path }/deliverable/' ,
185+ 'tmp_base_dir ' : '/tmp/docbuild' ,
186+ 'tmp_dir ' : '{tmp_base_dir }/doc-example-com' ,
187+ 'tmp_deliverable_dir ' : '{paths.tmp_dir }/deliverable/' ,
187188 },
188189 }
189190
0 commit comments