@@ -100,17 +100,16 @@ def test_background_color(config):
100100
101101def test_digest_file (tmp_path , config ):
102102 """Test that a config file can be digested programmatically."""
103- tmp_cfg = tempfile .NamedTemporaryFile ("w" , dir = tmp_path , delete = False )
104- tmp_cfg .write (
105- """
106- [CLI]
107- media_dir = this_is_my_favorite_path
108- video_dir = {media_dir}/videos
109- sections_dir = {media_dir}/{scene_name}/prepare_for_unforeseen_consequences
110- frame_height = 10
111- """ ,
112- )
113- tmp_cfg .close ()
103+ with tempfile .NamedTemporaryFile ("w" , dir = tmp_path , delete = False ) as tmp_cfg :
104+ tmp_cfg .write (
105+ """
106+ [CLI]
107+ media_dir = this_is_my_favorite_path
108+ video_dir = {media_dir}/videos
109+ sections_dir = {media_dir}/{scene_name}/prepare_for_unforeseen_consequences
110+ frame_height = 10
111+ """ ,
112+ )
114113 config .digest_file (tmp_cfg .name )
115114
116115 assert config .get_dir ("media_dir" ) == Path ("this_is_my_favorite_path" )
@@ -156,15 +155,14 @@ def test_custom_dirs(tmp_path, config):
156155
157156
158157def test_pixel_dimensions (tmp_path , config ):
159- tmp_cfg = tempfile .NamedTemporaryFile ("w" , dir = tmp_path , delete = False )
160- tmp_cfg .write (
161- """
162- [CLI]
163- pixel_height = 10
164- pixel_width = 10
165- """ ,
166- )
167- tmp_cfg .close ()
158+ with tempfile .NamedTemporaryFile ("w" , dir = tmp_path , delete = False ) as tmp_cfg :
159+ tmp_cfg .write (
160+ """
161+ [CLI]
162+ pixel_height = 10
163+ pixel_width = 10
164+ """ ,
165+ )
168166 config .digest_file (tmp_cfg .name )
169167
170168 # aspect ratio is set using pixel measurements
@@ -181,17 +179,16 @@ def test_frame_size(tmp_path, config):
181179 )
182180 np .testing .assert_allclose (config .frame_height , 8.0 )
183181
184- tmp_cfg = tempfile .NamedTemporaryFile ("w" , dir = tmp_path , delete = False )
185- tmp_cfg .write (
186- """
187- [CLI]
188- pixel_height = 10
189- pixel_width = 10
190- frame_height = 10
191- frame_width = 10
192- """ ,
193- )
194- tmp_cfg .close ()
182+ with tempfile .NamedTemporaryFile ("w" , dir = tmp_path , delete = False ) as tmp_cfg :
183+ tmp_cfg .write (
184+ """
185+ [CLI]
186+ pixel_height = 10
187+ pixel_width = 10
188+ frame_height = 10
189+ frame_width = 10
190+ """ ,
191+ )
195192 config .digest_file (tmp_cfg .name )
196193
197194 np .testing .assert_allclose (config .aspect_ratio , 1.0 )
@@ -235,14 +232,13 @@ def test_tex_template_file(tmp_path):
235232 """Test that a custom tex template file can be set from a config file."""
236233 tex_file = Path (tmp_path / "my_template.tex" )
237234 tex_file .write_text ("Hello World!" )
238- tmp_cfg = tempfile .NamedTemporaryFile ("w" , dir = tmp_path , delete = False )
239- tmp_cfg .write (
240- f"""
241- [CLI]
242- tex_template_file = { tex_file }
243- """ ,
244- )
245- tmp_cfg .close ()
235+ with tempfile .NamedTemporaryFile ("w" , dir = tmp_path , delete = False ) as tmp_cfg :
236+ tmp_cfg .write (
237+ f"""
238+ [CLI]
239+ tex_template_file = { tex_file }
240+ """ ,
241+ )
246242
247243 custom_config = ManimConfig ().digest_file (tmp_cfg .name )
248244
0 commit comments