@@ -175,12 +175,14 @@ def test_absolute_template_name_tpl_compatibility(self):
175175 assert exporter .template .filename == template
176176 assert os .path .dirname (template ) in exporter .template_paths
177177
178- def test_relative_template_name_tpl_compatibility (self ):
178+ # Can't use @pytest.mark.parametrize without removing all self.assert calls in all tests... repeating some here
179+ def relative_template_test (self , template ):
179180 with tempdir .TemporaryWorkingDirectory () as td :
180181 with patch ('os.getcwd' , return_value = os .path .abspath (td )):
181- template = os .path .join ('relative' , 'relative_template.tpl' )
182182 template_abs = os .path .abspath (os .path .join (td , template ))
183- os .mkdir (os .path .dirname (template_abs ))
183+ dirname = os .path .dirname (template_abs )
184+ if not os .path .exists (dirname ):
185+ os .mkdir (dirname )
184186 test_output = 'relative!'
185187 with open (template_abs , 'w' ) as f :
186188 f .write (test_output )
@@ -192,6 +194,18 @@ def test_relative_template_name_tpl_compatibility(self):
192194 assert os .path .abspath (exporter .template .filename ) == template_abs
193195 assert os .path .dirname (template_abs ) in [os .path .abspath (d ) for d in exporter .template_paths ]
194196
197+ def test_relative_template_name_tpl_compatibility_local (self ):
198+ self .relative_template_test ('relative_template.tpl' )
199+
200+ def test_relative_template_name_tpl_compatibility_nested (self ):
201+ self .relative_template_test (os .path .join ('relative' , 'relative_template.tpl' ))
202+
203+ def test_relative_template_name_tpl_compatibility_dot (self ):
204+ self .relative_template_test (os .path .join ('.' , 'relative_template.tpl' ))
205+
206+ def test_relative_template_name_tpl_compatibility_dot_nested (self ):
207+ self .relative_template_test (os .path .join ('.' , 'relative' , 'relative_template.tpl' ))
208+
195209 def test_absolute_template_dir (self ):
196210 with tempdir .TemporaryDirectory () as td :
197211 template = 'mytemplate'
0 commit comments