-
-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathtest_scripts_are_executable.py
More file actions
29 lines (20 loc) · 878 Bytes
/
Copy pathtest_scripts_are_executable.py
File metadata and controls
29 lines (20 loc) · 878 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
from __future__ import annotations
import os
from pathlib import Path
import pytest
PATH_CICD_SCRIPTS = Path(__file__).parents[3] / "cicd_utils/cicd/scripts"
CICD_PY_SCRIPTS = [
p
for p in PATH_CICD_SCRIPTS.iterdir()
if p.is_file() and p.suffix == ".py" and p.name != "__init__.py"
]
def test_cicd_py_scripts_not_empty() -> None:
assert len(CICD_PY_SCRIPTS) > 0
@pytest.mark.parametrize("script_path", CICD_PY_SCRIPTS, ids=[p.name for p in CICD_PY_SCRIPTS])
def test_py_scripts_are_executable(script_path: Path) -> None:
assert os.access(script_path, os.X_OK)
@pytest.mark.parametrize("script_path", CICD_PY_SCRIPTS, ids=[p.name for p in CICD_PY_SCRIPTS])
def test_py_scripts_have_py_shebang(script_path: Path) -> None:
with script_path.open("r") as f:
first_line = f.readline()
assert first_line.startswith("#!/usr/bin/env python")