This repository has been archived by the owner on Oct 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #34 from darrenburns/xfail-output
Outputting expected failures and unexpected passes
- Loading branch information
Showing
9 changed files
with
122 additions
and
47 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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,30 @@ | ||
from ward import expect | ||
from ward.test_result import TestResult, TestOutcome | ||
from ward.util import get_exit_code, ExitCode | ||
|
||
|
||
def test_get_exit_code_returns_success_when_skip_and_pass_and_xfail_present(example_test): | ||
test_results = [ | ||
TestResult(test=example_test, outcome=TestOutcome.PASS), | ||
TestResult(test=example_test, outcome=TestOutcome.SKIP), | ||
TestResult(test=example_test, outcome=TestOutcome.XFAIL), | ||
] | ||
exit_code = get_exit_code(test_results) | ||
|
||
expect(exit_code).equals(ExitCode.SUCCESS) | ||
|
||
|
||
def test_get_exit_code_returns_success_when_no_test_results(): | ||
exit_code = get_exit_code([]) | ||
|
||
expect(exit_code).equals(ExitCode.SUCCESS) | ||
|
||
|
||
def test_get_exit_code_returns_fail_when_xpass_present(example_test): | ||
test_results = [ | ||
TestResult(test=example_test, outcome=TestOutcome.XPASS), | ||
TestResult(test=example_test, outcome=TestOutcome.PASS), | ||
] | ||
exit_code = get_exit_code(test_results) | ||
|
||
expect(exit_code).equals(ExitCode.FAILED) |
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
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
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,18 @@ | ||
from enum import Enum | ||
from typing import Iterable | ||
|
||
from ward.test_result import TestOutcome, TestResult | ||
|
||
|
||
class ExitCode(Enum): | ||
SUCCESS = 0 | ||
FAILED = 1 | ||
ERROR = 2 | ||
|
||
|
||
def get_exit_code(results: Iterable[TestResult]) -> ExitCode: | ||
if any(r.outcome == TestOutcome.FAIL or r.outcome == TestOutcome.XPASS for r in results): | ||
exit_code = ExitCode.FAILED | ||
else: | ||
exit_code = ExitCode.SUCCESS | ||
return exit_code |