Skip to content

Commit

Permalink
MAYSKIP: tests: make examples_test run in parallel (mala-project#475)
Browse files Browse the repository at this point in the history
  • Loading branch information
elcorto committed Mar 18, 2024
1 parent 94ae65a commit 52a1e6d
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions test/examples_test.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,28 @@
"""Test whether the examples are still working."""
import importlib
import runpy
import os

import pytest


# There is https://github.com/RKrahl/pytest-dependency and
# https://github.com/pytest-dev/pytest-order but we like to keep in simple
# here. When running in parallel (pytest-xdist), we execute ex01 at most twice,
# which is OK.
def check_and_create_ex01_artifact():
if not os.path.exists("be_model.zip"):
print("Running example basic/ex01 in preparation another example")
runpy.run_path("../examples/basic/ex01_train_network.py")


@pytest.mark.examples
class TestExamples:
def test_basic_ex01(self):
runpy.run_path("../examples/basic/ex01_train_network.py")

def test_basic_ex02(self):
check_and_create_ex01_artifact()
runpy.run_path("../examples/basic/ex02_test_network.py")

def test_basic_ex03(self):
Expand All @@ -20,9 +32,11 @@ def test_basic_ex04(self):
runpy.run_path("../examples/basic/ex04_hyperparameter_optimization.py")

def test_basic_ex05(self):
check_and_create_ex01_artifact()
runpy.run_path("../examples/basic/ex05_run_predictions.py")

def test_basic_ex06(self):
check_and_create_ex01_artifact()
runpy.run_path("../examples/basic/ex06_ase_calculator.py")

def test_advanced_ex01(self):
Expand Down

0 comments on commit 52a1e6d

Please sign in to comment.