55import numpy as np
66import pytest
77
8- from manim import MathTex , SingleStringMathTex , Tex , TexTemplate , config , tempconfig
8+ from manim import MathTex , SingleStringMathTex , Tex , TexTemplate , tempconfig
99
1010
11- def test_MathTex ():
11+ def test_MathTex (config ):
1212 MathTex ("a^2 + b^2 = c^2" )
1313 assert Path (config .media_dir , "Tex" , "e4be163a00cf424f.svg" ).exists ()
1414
1515
16- def test_SingleStringMathTex ():
16+ def test_SingleStringMathTex (config ):
1717 SingleStringMathTex ("test" )
1818 assert Path (config .media_dir , "Tex" , "8ce17c7f5013209f.svg" ).exists ()
1919
@@ -27,7 +27,7 @@ def test_double_braces_testing(text_input, length_sub):
2727 assert len (t1 .submobjects ) == length_sub
2828
2929
30- def test_tex ():
30+ def test_tex (config ):
3131 Tex ("The horse does not eat cucumber salad." )
3232 assert Path (config .media_dir , "Tex" , "c3945e23e546c95a.svg" ).exists ()
3333
@@ -45,7 +45,7 @@ def test_tex_temp_directory(tmpdir, monkeypatch):
4545 assert Path ("media" , "Tex" , "c3945e23e546c95a.svg" ).exists ()
4646
4747
48- def test_percent_char_rendering ():
48+ def test_percent_char_rendering (config ):
4949 Tex (r"\%" )
5050 assert Path (config .media_dir , "Tex" , "4a583af4d19a3adf.tex" ).exists ()
5151
@@ -194,33 +194,33 @@ def test_error_in_nested_context(capsys):
194194 \end{align}
195195 """
196196
197- with pytest .raises (ValueError ) as err :
197+ with pytest .raises (ValueError ):
198198 Tex (invalid_tex )
199199
200200 stdout = str (capsys .readouterr ().out )
201201 # validate useless context is not included
202202 assert r"\begin{frame}" not in stdout
203203
204204
205- def test_tempconfig_resetting_tex_template ():
205+ def test_tempconfig_resetting_tex_template (config ):
206206 my_template = TexTemplate ()
207207 my_template .preamble = "Custom preamble!"
208- tex_template_config_value = config .tex_template
209208 with tempconfig ({"tex_template" : my_template }):
210209 assert config .tex_template .preamble == "Custom preamble!"
211210
212211 assert config .tex_template .preamble != "Custom preamble!"
213212
214213
215- def test_tex_garbage_collection (tmpdir , monkeypatch ):
214+ def test_tex_garbage_collection (tmpdir , monkeypatch , config ):
216215 monkeypatch .chdir (tmpdir )
217216 Path (tmpdir , "media" ).mkdir ()
217+ config .media_dir = "media"
218218
219- with tempconfig ({"media_dir" : "media" }):
220- tex_without_log = Tex ("Hello World!" ) # d771330b76d29ffb.tex
221- assert Path ("media" , "Tex" , "d771330b76d29ffb.tex" ).exists ()
222- assert not Path ("media" , "Tex" , "d771330b76d29ffb.log" ).exists ()
219+ tex_without_log = Tex ("Hello World!" ) # d771330b76d29ffb.tex
220+ assert Path ("media" , "Tex" , "d771330b76d29ffb.tex" ).exists ()
221+ assert not Path ("media" , "Tex" , "d771330b76d29ffb.log" ).exists ()
222+
223+ config .no_latex_cleanup = True
223224
224- with tempconfig ({"media_dir" : "media" , "no_latex_cleanup" : True }):
225- tex_with_log = Tex ("Hello World, again!" ) # da27670a37b08799.tex
226- assert Path ("media" , "Tex" , "da27670a37b08799.log" ).exists ()
225+ tex_with_log = Tex ("Hello World, again!" ) # da27670a37b08799.tex
226+ assert Path ("media" , "Tex" , "da27670a37b08799.log" ).exists ()
0 commit comments