File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed
Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -86,6 +86,35 @@ def test_fails(tmpdir):
8686 assert code == 0
8787
8888
89+ TEST_OUTPUT_DIR = """
90+ import pytest
91+ import matplotlib.pyplot as plt
92+ @pytest.mark.mpl_image_compare
93+ def test_output_dir():
94+ fig = plt.figure()
95+ ax = fig.add_subplot(1, 1, 1)
96+ ax.plot([1, 2, 3])
97+ return fig
98+ """
99+
100+
101+ def test_output_dir (tmpdir ):
102+ test_file = tmpdir .join ('test.py' ).strpath
103+ with open (test_file , 'w' ) as f :
104+ f .write (TEST_OUTPUT_DIR )
105+
106+ # When we run the test, we should get output images where we specify
107+ output_dir = tmpdir .join ('test_output_dir' ).strpath
108+ code = subprocess .call ('py.test --mpl-results-path={0} --mpl {1}' .format (output_dir , test_file ),
109+ shell = True )
110+
111+ assert code != 0
112+ assert os .path .exists (output_dir )
113+
114+ # Listdir() is to get the random name that the output for the one test is written into
115+ assert os .path .exists (os .path .join (output_dir , os .listdir (output_dir )[0 ], 'test_output_dir.png' ))
116+
117+
89118TEST_GENERATE = """
90119import pytest
91120import matplotlib.pyplot as plt
You can’t perform that action at this time.
0 commit comments