From 4834ff792097ecb512c7a4e57de5f6eb4e5f07c0 Mon Sep 17 00:00:00 2001 From: Mike Henry <11765982+mikemhenry@users.noreply.github.com> Date: Mon, 24 Jul 2023 08:49:54 -0700 Subject: [PATCH] Remove example testing (#1214) --- perses/tests/test_examples.py | 72 ----------------------------------- 1 file changed, 72 deletions(-) delete mode 100644 perses/tests/test_examples.py diff --git a/perses/tests/test_examples.py b/perses/tests/test_examples.py deleted file mode 100644 index 707164a1e..000000000 --- a/perses/tests/test_examples.py +++ /dev/null @@ -1,72 +0,0 @@ -#!/usr/bin/env python - -# ====================================================================== -# MODULE DOCSTRING -# ====================================================================== - -""" -Test that the examples in the repo run without errors. -""" - -# ====================================================================== -# GLOBAL IMPORTS -# ====================================================================== - -import sys - -import pathlib -import pytest -import subprocess -from perses.tests.utils import enter_temp_directory - -ROOT_DIR_PATH = pathlib.Path(__file__).joinpath("../../../").resolve() -SLOW_EXAMPLES_KEYWORDS = ("barnase-barstar", "kinase-neq-switching") -NOT_EXAMPLES_KEYWORDS = ("analyze-benchmark", "moonshot-mainseries") - - -def run_script_file(file_path, cmd_args=None): - """Run through the shell a python script.""" - with enter_temp_directory(): - # Make sure we grab the python executable in our env - cmd = [f"{sys.executable}", file_path] - print(cmd) - # Extend cmd list with given cmd_args - if cmd_args: - cmd.extend(cmd_args) - try: - subprocess.run(cmd, capture_output=True, check=True, shell=True) - except subprocess.CalledProcessError as error: - raise Exception(f"Example {file_path} failed. STDERR: {error.stderr.decode()}") - - -def find_example_scripts(): - """Find all Python scripts, excluding Jupyter notebooks, in the examples folder. - Returns - ------- - example_file_paths : List[str] - List of full paths to python scripts to execute. - """ - examples_dir_path = ROOT_DIR_PATH.joinpath("examples") - - example_file_paths = [] - for example_file_path in examples_dir_path.glob("*/*.py"): - # TODO: find a better way to mark slow examples - example_posix_path = example_file_path.as_posix() - # mark slow examples - if any(example in example_posix_path for example in SLOW_EXAMPLES_KEYWORDS): - example_posix_path = pytest.param(example_posix_path, marks=pytest.mark.slow) - # mark non-examples - elif any(example in example_posix_path for example in NOT_EXAMPLES_KEYWORDS): - example_posix_path = pytest.param(example_posix_path, marks=pytest.mark.skip("not an example")) - example_file_paths.append(example_posix_path) - - return example_file_paths - - -# ====================================================================== -# TESTS -# ====================================================================== -@pytest.mark.parametrize("example_file_path", find_example_scripts()) -def test_examples(example_file_path): - """Test that the example run without errors.""" - run_script_file(example_file_path)