-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
72 additions
and
38 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
# Env variables for tests | ||
TESTING=YES | ||
LOG_LEVEL=DEBUG | ||
SITE_NAME=萌翻TEST | ||
SECRET_KEY=SECRET | ||
|
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 |
---|---|---|
@@ -1,21 +1,41 @@ | ||
venv: | ||
python3 -mvenv venv | ||
PYTEST_COV_ARGS = --cov=app --cov-report=term --cov-report=xml:cov.xml | ||
|
||
FORCE: ; | ||
|
||
create-venv: | ||
python3.10 -mvenv venv | ||
|
||
deps: | ||
venv/bin/pip install -r requirements.txt | ||
|
||
remove-venv: FORCE | ||
rm -rf venv | ||
|
||
recreate-venv: remove-venv create-venv | ||
|
||
format: | ||
venv/bin/ruff format | ||
|
||
test: | ||
@./pytest --html=report.html --self-contained-html | ||
requirements.txt: deps-top.txt recreate-venv | ||
venv/bin/pip install -r deps-top.txt | ||
echo '# GENERATED: run make requirements.txt to recreate lock file' > requirements.txt | ||
venv/bin/pipdeptree --freeze >> requirements.txt | ||
|
||
test: test_all | ||
|
||
test_all_cov: | ||
venv/bin/pytest --html=report.html --self-contained-html ${PYTEST_COV_ARGS[@]} | ||
|
||
test_all: | ||
venv/bin/pytest --html=report.html --self-contained-html | ||
|
||
test_p: | ||
@./pytest -n 8 | ||
test_all_parallel: | ||
venv/bin/pytest -n 8 | ||
|
||
test_single: | ||
@bash -c "set -uexo allexport && source .env.test && exec venv/bin/pytest --capture=sys --log-cli-level=DEBUG tests/base/test_not_exist_error.py" | ||
venv/bin/pytest tests/base/test_not_exist_error.py | ||
|
||
test_logging: | ||
#--capture=no | ||
# WTF: setting level to above WARNING not working? | ||
@bash -c "set -uexo allexport && source .env.test && exec venv/bin/pytest --capture=sys --log-cli-level=DEBUG tests/base/test_it_runs.py" | ||
# @bash -c "set -uexo allexport && source .env.test && exec venv/bin/pytest --capture=sys --log-cli-level=DEBUG tests/base/test_it_runs.py" |
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 |
---|---|---|
@@ -1,9 +1,9 @@ | ||
[pytest] | ||
generate_report_on_test = True | ||
; 覆盖率配置,需要时开启(可配合VSCode的Coverage Gutters使用) | ||
addopts = -s | ||
; addopts = -s --cov=app --cov-report=term --cov-report=xml:cov.xml | ||
addopts = --log-level=INFO | ||
; 忽略第三方库Warining | ||
filterwarnings = | ||
ignore:count is deprecated. Use Collection.count_documents instead.:DeprecationWarning | ||
ignore:Using or importing the ABCs .* is deprecated.*:DeprecationWarning | ||
env_files = .env.test |
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