Coverage for test_examples.py: 93%

15 statements  

« prev     ^ index     » next       coverage.py v7.5.1, created at 2024-05-08 14:15 +0200

1import os 

2import subprocess 

3import sys 

4from glob import glob 

5from pathlib import Path 

6 

7import pytest 

8 

9 

10def get_examples(): 

11 # Where are we? --> __file__ 

12 # Move three up. 

13 path = Path(__file__).parent.parent.parent 

14 relpath = Path(os.path.relpath(path, os.getcwd())) / "examples/**/*.py" 

15 examples = [f for f in glob(str(relpath)) if f.endswith(".py")] 

16 return examples 

17 

18 

19@pytest.mark.example 

20@pytest.mark.parametrize("example", get_examples()) 

21def test_example(example): 

22 subprocess.run([sys.executable, example], check=True)