Skip to content

Commit

Permalink
squash: fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
happz committed Jan 13, 2025
1 parent fc1aea3 commit 7a4c0a1
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions tests/unit/test_results.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from typing import Optional
from unittest.mock import MagicMock

import pytest
Expand Down Expand Up @@ -100,14 +99,14 @@ def test_result_to_exit_code(outcomes: list[ResultOutcome], expected_exit_code:
ResultInterpret.RESPECT,
{"check1": CheckResultInterpret.RESPECT},
ResultOutcome.PASS,
None
[]
),
(
ResultOutcome.FAIL,
ResultInterpret.RESPECT,
{"check1": CheckResultInterpret.RESPECT},
ResultOutcome.FAIL,
"check 'check1' failed" # Note is set when check fails
["check 'check1' failed"] # Note is set when check fails
),
# Test XFAIL interpretation
Expand All @@ -116,14 +115,14 @@ def test_result_to_exit_code(outcomes: list[ResultOutcome], expected_exit_code:
ResultInterpret.XFAIL,
{"check1": CheckResultInterpret.RESPECT},
ResultOutcome.PASS,
"check 'check1' failed, test failed as expected, original test result: fail"
["check 'check1' failed", "test failed as expected", "original test result: fail"]
),
(
ResultOutcome.PASS,
ResultInterpret.XFAIL,
{"check1": CheckResultInterpret.RESPECT},
ResultOutcome.FAIL,
"test was expected to fail, original test result: pass"
["test was expected to fail", "original test result: pass"]
),
# Test INFO interpretation
Expand All @@ -132,14 +131,14 @@ def test_result_to_exit_code(outcomes: list[ResultOutcome], expected_exit_code:
ResultInterpret.INFO,
{"check1": CheckResultInterpret.RESPECT},
ResultOutcome.INFO,
"check 'check1' failed, test result overridden: info, original test result: fail"
["check 'check1' failed", "test result overridden: info", "original test result: fail"]
),
(
ResultOutcome.PASS,
ResultInterpret.INFO,
{"check1": CheckResultInterpret.RESPECT},
ResultOutcome.INFO,
"test result overridden: info, original test result: pass"
["test result overridden: info", "original test result: pass"]
),
# Test WARN interpretation
Expand All @@ -148,7 +147,7 @@ def test_result_to_exit_code(outcomes: list[ResultOutcome], expected_exit_code:
ResultInterpret.WARN,
{"check1": CheckResultInterpret.RESPECT},
ResultOutcome.WARN,
"test result overridden: warn, original test result: pass"
["test result overridden: warn", "original test result: pass"]
),
# Test ERROR interpretation
Expand All @@ -157,7 +156,7 @@ def test_result_to_exit_code(outcomes: list[ResultOutcome], expected_exit_code:
ResultInterpret.ERROR,
{"check1": CheckResultInterpret.RESPECT},
ResultOutcome.ERROR,
"test result overridden: error, original test result: pass"
["test result overridden: error", "original test result: pass"]
),
# Test CUSTOM interpretation (should not modify result)
Expand All @@ -166,7 +165,7 @@ def test_result_to_exit_code(outcomes: list[ResultOutcome], expected_exit_code:
ResultInterpret.CUSTOM,
{"check1": CheckResultInterpret.RESPECT},
ResultOutcome.FAIL,
None
[]
),
],
ids=[
Expand All @@ -183,7 +182,7 @@ def test_result_interpret_all_cases(
interpret: ResultInterpret,
interpret_checks: dict[str, CheckResultInterpret],
expected_outcome: ResultOutcome,
expected_note_contains: Optional[str]
expected_note_contains: list[str]
) -> None:
"""Test all possible combinations of result interpretations"""
result = Result(
Expand All @@ -198,10 +197,11 @@ def test_result_interpret_all_cases(
assert interpreted.result == expected_outcome

if expected_note_contains:
assert interpreted.note is not None
assert expected_note_contains in interpreted.note
assert interpreted.note
for expected_note in expected_note_contains:
assert expected_note in interpreted.note
else:
assert interpreted.note is None
assert not interpreted.note


def test_result_interpret_check_phases() -> None:
Expand Down Expand Up @@ -238,10 +238,10 @@ def test_result_interpret_edge_cases() -> None:
result = Result(name="test-case", result=ResultOutcome.FAIL)
interpreted = result.interpret_result(ResultInterpret.RESPECT, {})
assert interpreted.result == ResultOutcome.FAIL
assert interpreted.note is None
assert not interpreted.note

# Test with empty check list
result = Result(name="test-case", result=ResultOutcome.FAIL, check=[])
interpreted = result.interpret_result(ResultInterpret.RESPECT, {})
assert interpreted.result == ResultOutcome.FAIL
assert interpreted.note is None
assert not interpreted.note

0 comments on commit 7a4c0a1

Please sign in to comment.