Skip to content

Commit

Permalink
Add summary only option - Fail a test intentionally
Browse files Browse the repository at this point in the history
  • Loading branch information
faboshka committed Jan 5, 2024
1 parent f386d09 commit be78f2f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ jobs:
- name: Install poetry
run: python -m pip install poetry
- name: Install dependencies
run: poetry install --only main,test
run: |
poetry add pytest-github-actions-annotate-failures@latest --group=test
poetry install --only main,test
- name: Run tests
run: poetry run pytest tests --junitxml=junit.xml -n auto
- name: Test reporter
Expand All @@ -35,3 +37,5 @@ jobs:
path: junit.xml
reporter: java-junit
output-to: step-summary
only-summary: true
max-annotations: 0
8 changes: 7 additions & 1 deletion tests/test_secret_santa.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,16 @@
from secret_santa.util import misc


# TODO: Remove in refactor and get rid of env load as this has some unintended side effects
@pytest.fixture(autouse=True)
def clear_environment(mocker: MockerFixture) -> Iterator:
# This is essentially a pretest to clear the environment, as all tests run in the same session
# with environment variables loaded from another tests.
mocker.patch.dict(os.environ, {}, clear=True)
# Note:
# Until this is taken care of properly - the GitHub actions environment variables should not be cleared if exists.
is_github_env_var = lambda key: any(key.startswith(gh_env_prefix) for gh_env_prefix in ["GITHUB_", "RUNNER_"])

Check failure on line 28 in tests/test_secret_santa.py

View workflow job for this annotation

GitHub Actions / lint

Ruff (E731)

tests/test_secret_santa.py:28:5: E731 Do not assign a `lambda` expression, use a `def`
github_env_variables = {key: val for key, val in os.environ.items() if is_github_env_var(key)}
mocker.patch.dict(os.environ, {**github_env_variables}, clear=True)
yield


Expand Down Expand Up @@ -158,6 +163,7 @@ def test_env_file_value_override_existing(
system_values: list[tuple[str, str]],
expected: list[tuple[str, str]],
) -> None:
assert False

Check failure on line 166 in tests/test_secret_santa.py

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, 3.12)

test_env_file_value_override_existing[True-system_values0-expected0] assert False

Check failure on line 166 in tests/test_secret_santa.py

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, 3.12)

test_env_file_value_override_existing[False-system_values1-expected1] assert False
for env_key, env_value in system_values:
monkeypatch.setenv(env_key, env_value)
load_env(dotenv_path=test_env_file_path, override_system=override_system)
Expand Down

0 comments on commit be78f2f

Please sign in to comment.