-
Notifications
You must be signed in to change notification settings - Fork 11
feat: using pytest as a test runner, diversify the tests into unit, integration, and performance tests #1028
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
191b194
test: using pytest as a test runner, diversify the tests into unit, i…
jenstroeger ca2e6e5
test: run only unit tests for the local git push hook
jenstroeger 2e30862
docs: improve module docstrings for tests
jenstroeger 567c636
chore: add explanations for pytest markers
jenstroeger 86bf9af
chore: improve Makefile and how & when to run what tests
jenstroeger bc93ec4
chore: call pytest directly from the Makefile instead of the pre-comm…
jenstroeger 345b862
chore: run unit tests only from the git push hook
jenstroeger f3961e5
fix: run flit through the venv’s python interpreter instead of callin…
jenstroeger 1babae2
chore: disable coverage tracking for integration tests and performanc…
jenstroeger 53d65c5
chore: remove changes to running flit
jenstroeger 01dfc17
chore: improve comment
jenstroeger 27c31c0
docs: update README
jenstroeger File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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,16 @@ | ||
| """Test the Package itself using its external interface as in integration into a larger run context.""" | ||
|
|
||
| # https://bandit.readthedocs.io/en/latest/blacklists/blacklist_imports.html#b404-import-subprocess | ||
| import subprocess # nosec B404 | ||
|
|
||
| import pytest | ||
|
|
||
|
|
||
| @pytest.mark.integration | ||
| def test_package() -> None: | ||
| """Test the Something command.""" | ||
| # For testing we disable this warning here: | ||
| # https://bandit.readthedocs.io/en/latest/plugins/b603_subprocess_without_shell_equals_true.html | ||
| # https://bandit.readthedocs.io/en/latest/plugins/b607_start_process_with_partial_path.html | ||
| completed = subprocess.run(["something"], check=True, shell=False) # nosec B603, B607 | ||
| assert completed.returncode == 0 |
This file contains hidden or 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,12 @@ | ||
| """Test the performance of various package parts, or the package as a whole.""" | ||
|
|
||
| import pytest | ||
| from pytest_benchmark.fixture import BenchmarkFixture | ||
|
|
||
| from package.something import Something | ||
|
|
||
|
|
||
| @pytest.mark.performance | ||
| def test_something(benchmark: BenchmarkFixture) -> None: | ||
| """Test performance of the function.""" | ||
| benchmark.pedantic(Something.do_something, iterations=10, rounds=100) # type: ignore[no-untyped-call] |
File renamed without changes.
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.