Skip to content

Commit

Permalink
Use tmpdir
Browse files Browse the repository at this point in the history
  • Loading branch information
AlejandroFernandezLuces committed Nov 17, 2023
1 parent 32a3763 commit 4207d79
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions tests/plotting/test_plotter.py
Original file line number Diff line number Diff line change
Expand Up @@ -468,29 +468,28 @@ def test_plotter_update_coordinates(sphere):
raise RuntimeError("Remove this method")


def test_only_screenshots_flag(sphere):
def test_only_screenshots_flag(sphere, tmpdir):
tmpscreenshots = pv.ON_SCREENSHOT
tmpfigurepath = pv.FIGURE_PATH

pv.FIGURE_PATH = str(tmpdir)

pv.ON_SCREENSHOT = True
entries = os.listdir(".")
entries = os.listdir(pv.FIGURE_PATH)
pl = pv.Plotter()
pl.add_mesh(sphere)
pl.show()
entries_after = os.listdir(".")
entries_after = os.listdir(pv.FIGURE_PATH)
assert len(entries) == len(entries_after) - 1
res_file = list(set(entries_after) - set(entries))[0]

pv.ON_SCREENSHOT = False
sphere_screenshot = "sphere_screenshot.png"
pl = pv.Plotter()
pl.add_mesh(sphere)
pl.show(screenshot=sphere_screenshot)

error = pv.compare_images(sphere_screenshot, res_file)

sphere_path = os.path.join(pv.FIGURE_PATH, sphere_screenshot)
res_path = os.path.join(pv.FIGURE_PATH, res_file)
error = pv.compare_images(sphere_path, res_path)
assert error < 100
pv.ON_SCREENSHOT = tmpscreenshots
pv.FIGURE_PATH = tmpfigurepath
os.remove(sphere_screenshot)
os.remove(res_file)

0 comments on commit 4207d79

Please sign in to comment.