Skip to content

Commit

Permalink
ENH: skip eps_writer test if 'tex' executable isn't installed
Browse files Browse the repository at this point in the history
  • Loading branch information
neutrinoceros committed Sep 1, 2021
1 parent d8687fa commit a7a1603
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
24 changes: 24 additions & 0 deletions yt/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import shutil
import tempfile
import unittest
from shutil import which

import matplotlib
import numpy as np
Expand Down Expand Up @@ -1364,6 +1365,29 @@ def ftrue(func):
return ffalse


def requires_external_executable(*names):
import pytest

def deco(func):
missing = []
for name in names:
if which(name) is None:
missing.append(name)

# note that order between these two decorators matters
@pytest.mark.skipif(
missing,
reason=f"missing external executable(s): {', '.join(missing)}",
)
@functools.wraps(func)
def inner_func(*args, **kwargs):
return func(*args, **kwargs)

return inner_func

return deco


class TempDirTest(unittest.TestCase):
"""
A test class that runs in a temporary directory and
Expand Down
3 changes: 2 additions & 1 deletion yt/visualization/tests/test_eps_writer.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import yt
from yt.testing import fake_amr_ds, requires_module
from yt.testing import fake_amr_ds, requires_external_executable, requires_module


@requires_external_executable("tex")
@requires_module("pyx")
def test_eps_writer(tmp_path):
import yt.visualization.eps_writer as eps
Expand Down

0 comments on commit a7a1603

Please sign in to comment.