-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: initial implementation of top-level pytest tests (#433)
``` $ poetry init $ poetry add --dev pytest $ poetry add --dev pytest-subtests ```
- Loading branch information
Showing
7 changed files
with
217 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
[tool.poetry] | ||
name = "notebooks" | ||
version = "2024.1" | ||
authors = [] | ||
description = "Open Data Hub / OpenShift AI Notebook / Workbench images, and tests for the same in Python." | ||
readme = "README.md" | ||
package-mode = false | ||
|
||
[tool.poetry.dependencies] | ||
python = "~3.12" | ||
|
||
|
||
[tool.poetry.group.dev.dependencies] | ||
pytest = "^8.2.2" | ||
pytest-subtests = "^0.12.1" | ||
|
||
[build-system] | ||
requires = ["poetry-core"] | ||
build-backend = "poetry.core.masonry.api" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# https://docs.pytest.org/en/7.1.x/reference/reference.html#configuration-options | ||
|
||
[pytest] | ||
addopts = --strict-markers --capture=no --tb=short | ||
|
||
required_plugins = pytest-subtests | ||
|
||
junit_logging = all | ||
junit_log_passing_tests = False | ||
|
||
log_cli = True | ||
log_cli_date_format = %Y-%m-%d %H:%M:%S | ||
log_cli_format = %(asctime)s %(levelname)s %(message)s | ||
log_cli_level = INFO | ||
|
||
log_file = logs/pytest-logs.txt | ||
log_file_level = DEBUG |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from __future__ import annotations | ||
|
||
import pathlib | ||
import tomllib | ||
from typing import TYPE_CHECKING | ||
|
||
if TYPE_CHECKING: | ||
import pytest_subtests | ||
|
||
PROJECT_ROOT = pathlib.Path(__file__).parent.parent | ||
|
||
|
||
def test_image_pipfiles(subtests: pytest_subtests.plugin.SubTests): | ||
for file in PROJECT_ROOT.glob("**/Pipfile"): | ||
with subtests.test(msg="checking Pipfile", pipfile=file): | ||
directory = file.parent # "ubi9-python-3.9" | ||
ubi, lang, python = directory.name.split("-") | ||
|
||
with open(file, "rb") as fp: | ||
pipfile = tomllib.load(fp) | ||
assert "requires" in pipfile, "Pipfile is missing a [[requires]] section" | ||
assert pipfile["requires"]["python_version"] == python, "Pipfile does not declare the expected Python version" |