icm/test_guidelines.py

51 lines
1.4 KiB
Python

"""
Testing guidelines and install
"""
import os
import unittest
from subprocess import run, CalledProcessError
import pathlib
class TestGuidelines(unittest.TestCase):
def test_git(self):
"The poj"
assert run(["git", "status"], check=True)
def test_has_requirement(self):
root_dir = run(
["git", "rev-parse", "--show-toplevel"], capture_output=True, text=True
).stdout.strip()
target = pathlib.Path(root_dir) / "requirements.txt"
assert target.exists()
assert target.is_file()
def test_has_readme(self):
root_dir = run(
["git", "rev-parse", "--show-toplevel"], capture_output=True, text=True
).stdout.strip()
target = pathlib.Path(root_dir) / "README.rst"
assert target.exists()
assert target.is_file()
@unittest.skipIf(os.environ.get("already_in_venv"), "Avoid self call infinite loop")
def test_environment(self):
"""We want to make sure that the project is virtualenv compatible.
we may provie and extra makefile for that (and automate build phase)
"""
venv = "-f", "MakefileVenv"
for step in ["clean", "install", "test"]:
with self.subTest(setp=step):
try:
run(["make", *venv, step], check=True)
except CalledProcessError as E:
print(E.output)
raise