test_examples   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 4
eloc 24
dl 0
loc 34
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A TestTutorial.test_registry() 0 11 1

1 Function

Rating   Name   Duplication   Size   Complexity  
A execute_commands() 0 9 3
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