From 44067cfeb1fbc185e34070b5ec8a954a8c15e4bc Mon Sep 17 00:00:00 2001 From: Arisu Tachibana Date: Thu, 12 Sep 2024 13:25:33 +0900 Subject: [PATCH] pytest: Add simple functional pytest Signed-off-by: Arisu Tachibana --- .github/workflows/poetry.yml | 2 ++ tests/test_kcidev.py | 38 ++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 tests/test_kcidev.py diff --git a/.github/workflows/poetry.yml b/.github/workflows/poetry.yml index b2a6be4..71c0b5b 100644 --- a/.github/workflows/poetry.yml +++ b/.github/workflows/poetry.yml @@ -26,3 +26,5 @@ jobs: run: poetry run black --check --verbose . - name: Isort check run: poetry run isort . --check --diff + - name: Pytest check + run: poetry run pytest -rP diff --git a/tests/test_kcidev.py b/tests/test_kcidev.py new file mode 100644 index 0000000..966803b --- /dev/null +++ b/tests/test_kcidev.py @@ -0,0 +1,38 @@ +from subprocess import PIPE, run +import os + +def test_prepare(): + os.system("cp .kci-dev.toml.example .kci-dev.toml") + assert os.path.exists(".kci-dev.toml") + +def test_kcidev_help(): + command = ["poetry", "run", "kci-dev", "--help"] + result = run(command, stdout=PIPE, stderr=PIPE, universal_newlines=True) + print("returncode: " + str(result.returncode)) + print("#### stdout ####") + print(result.stdout) + print("#### stderr ####") + print(result.stderr) + assert result.returncode == 0 + + +def test_kcidev_commit_help(): + command = ["poetry", "run", "kci-dev", "commit", "--help"] + result = run(command, stdout=PIPE, stderr=PIPE, universal_newlines=True) + print("returncode: " + str(result.returncode)) + print("#### stdout ####") + print(result.stdout) + print("#### stderr ####") + print(result.stderr) + assert result.returncode == 0 + + +def test_kcidev_patch_help(): + command = ["poetry", "run", "kci-dev", "patch", "--help"] + result = run(command, stdout=PIPE, stderr=PIPE, universal_newlines=True) + print("returncode: " + str(result.returncode)) + print("#### stdout ####") + print(result.stdout) + print("#### stderr ####") + print(result.stderr) + assert result.returncode == 0