test_examples.execute_commands()   A
last analyzed

Complexity

Conditions 3

Size

Total Lines 9
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 9
rs 9.95
c 0
b 0
f 0
cc 3
nop 1
1
import subprocess
2
3
import pytest
4
5
from deepreg import log
6
7
logger = log.get(__name__)
8
9
10
def execute_commands(cmds):
11
    for cmd in cmds:
12
        try:
13
            logger.info(f"Running {cmd}")
14
            out = subprocess.check_output(cmd, shell=True).decode("utf-8")
15
            logger.info(out)
16
        except subprocess.CalledProcessError as e:
17
            raise RuntimeError(
18
                f"Command {cmd} return with err {e.returncode} {e.output}"
19
            )
20
21
22
class TestTutorial:
23
    @pytest.mark.parametrize(
24
        "name",
25
        [
26
            "custom_backbone",
27
            "custom_image_label_loss",
28
            "custom_parameterized_image_label_loss",
29
        ],
30
    )
31
    def test_registry(self, name: str):
32
        cmds = [f"python examples/{name}.py"]
33
        execute_commands(cmds)
34