-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added remaining tests for app functions
- Loading branch information
1 parent
720719e
commit 81e27cf
Showing
5 changed files
with
143 additions
and
52 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
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,21 @@ | ||
"""Testing utils.""" | ||
|
||
from click.testing import CliRunner | ||
|
||
|
||
def run_click_script(func, args: list[str], catch_exceptions: bool = False): | ||
"""Util to test click scripts while showing the stdout.""" | ||
|
||
runner = CliRunner() | ||
|
||
# We catch the exception here no matter what, but we'll reraise later if need be. | ||
result = runner.invoke(func, args, catch_exceptions=True) | ||
|
||
# Without this the output to stdout/stderr is grabbed by click's test runner. | ||
# print(result.output) | ||
|
||
# In case of an exception, raise it so that the test fails with the exception. | ||
if result.exception and not catch_exceptions: | ||
raise result.exception | ||
|
||
return result |
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