Skip to content
Snippets Groups Projects
Unverified Commit 56ce962d authored by Fredrik Jonsson's avatar Fredrik Jonsson Committed by GitHub
Browse files

Merge pull request #2954 from HyphaApp/improve-testing

Improve testing and development experience
parents 84f1eaa9 a65345a4
No related branches found
No related tags found
No related merge requests found
...@@ -96,7 +96,7 @@ jobs: ...@@ -96,7 +96,7 @@ jobs:
command: | command: |
python3 -m venv venv python3 -m venv venv
. venv/bin/activate . venv/bin/activate
pip install coverage codecov pip install codecov pytest-circleci-parallelized
pip install -r requirements-dev.txt pip install -r requirements-dev.txt
- save_cache: - save_cache:
paths: paths:
...@@ -118,12 +118,12 @@ jobs: ...@@ -118,12 +118,12 @@ jobs:
name: run linting name: run linting
command: | command: |
. venv/bin/activate . venv/bin/activate
flake8 ./hypha make lint
make sort
test-be: test-be:
executor: with-database executor: with-database
working_directory: ~/repo working_directory: ~/repo
parallelism: 4
steps: steps:
- checkout - checkout
- attach_workspace: - attach_workspace:
...@@ -135,7 +135,7 @@ jobs: ...@@ -135,7 +135,7 @@ jobs:
python manage.py check python manage.py check
python manage.py makemigrations --check --noinput --verbosity=1 python manage.py makemigrations --check --noinput --verbosity=1
python manage.py collectstatic --noinput --no-post-process --verbosity=1 python manage.py collectstatic --noinput --no-post-process --verbosity=1
coverage run --source='hypha' manage.py test pytest --cov --cov-report term:skip-covered -n 1 --circleci-parallelize
codecov codecov
......
...@@ -32,10 +32,12 @@ wheels/ ...@@ -32,10 +32,12 @@ wheels/
*.egg-info/ *.egg-info/
.installed.cfg .installed.cfg
*.egg *.egg
.coverage
htmlcov/
# Cache # Cache
.mypy_cache/ .mypy_cache/
.pytest_cache/
# Webpack # Webpack
webpack-stats.json webpack-stats.json
......
.nvmrc 0 → 100644
v16.14.2
...@@ -3,6 +3,9 @@ help: ...@@ -3,6 +3,9 @@ help:
@echo "Usage:" @echo "Usage:"
@echo " make help prints this help." @echo " make help prints this help."
@echo " make lint run all python linting." @echo " make lint run all python linting."
@echo " make test run linting and test and generate html coverage report"
@echo " make py-test run all python tests and display coverage"
@echo " make cov-html generate html coverage report"
@echo " make sort run the isort import linter." @echo " make sort run the isort import linter."
@echo " make sort-fix fix import sort order." @echo " make sort-fix fix import sort order."
@echo " make style run the python code style linter." @echo " make style run the python code style linter."
...@@ -12,12 +15,30 @@ lint: sort style ...@@ -12,12 +15,30 @@ lint: sort style
.PHONY: sort .PHONY: sort
sort: sort:
@echo "Checking imports with isort" && isort --check-only --diff . @echo "Checking imports with isort" && isort --check-only --diff hypha
.PHONY: sort-fix .PHONY: sort-fix
sort-fix: sort-fix:
@echo "Fixing imports with isort" && isort . @echo "Fixing imports with isort" && isort hypha
.PHONY: style .PHONY: style
style: style:
@echo "Checking code style with flake8" && flake8 . @echo "Checking code style with flake8" && flake8 .
.PHONY: cov-htmlcov
cov-html:
ifneq ("$(wildcard .coverage)","")
@rm -rf htmlcov
@echo "Generate html coverage report..." && coverage html
@echo "Open 'htmlcov/index.html' in your browser to see the report."
else
$(error Unable to generate html coverage report, please run 'make test' or 'make py-test')
endif
.PHONY: py-test
py-test:
@echo "Running python tests"
pytest --reuse-db --cov --cov-report term:skip-covered
.PHONY: test
test: lint py-test cov-html
...@@ -24,3 +24,6 @@ PASSWORD_HASHERS = [ ...@@ -24,3 +24,6 @@ PASSWORD_HASHERS = [
] ]
WAGTAILADMIN_BASE_URL = "https://primary-test-host.org" WAGTAILADMIN_BASE_URL = "https://primary-test-host.org"
# Required by django-coverage-plugin to report template coverage
TEMPLATES[0]['OPTIONS']['debug'] = True
-r requirements.txt -r requirements.txt
django-debug-toolbar==3.2.2 django-debug-toolbar==3.6.0
factory_boy==3.2.1 factory_boy==3.2.1
flake8==5.0.1 flake8==5.0.4
isort==5.10.1 isort==5.10.1
model-bakery==1.3.3 model-bakery==1.7.0
responses==0.16.0 responses==0.21.0
stellar==0.4.5 stellar==0.4.5
wagtail-factories==2.1.0 wagtail-factories==2.1.0
Werkzeug==2.0.2 Werkzeug==2.2.2
pytest-django==4.5.2
pytest-xdist[psutil]==2.5.0
coverage==6.4.4
pytest-cov==3.0.0
django-coverage-plugin==2.0.3
[flake8] [flake8]
ignore = E501,W503,F405,F821,W504,W605 ignore = E501,W503,F405,F821,W504,W605
exclude = migrations,node_modules,venv
max-line-length = 88 max-line-length = 88
exclude =
.*/,
__pycache__/,
*migrations/,
node_modules/,
venv/,
media/,
static/,
htmlcov/
[isort] [isort]
force_grid_wrap = 0 force_grid_wrap = 0
...@@ -10,3 +18,19 @@ line_length = 88 ...@@ -10,3 +18,19 @@ line_length = 88
multi_line_output = 3 multi_line_output = 3
skip_glob = .direnv,node_modules,venv,**/migrations/** skip_glob = .direnv,node_modules,venv,**/migrations/**
use_parentheses = True use_parentheses = True
[tool:pytest]
DJANGO_SETTINGS_MODULE = hypha.settings.test
addopts = -n auto --failed-first
python_files = tests.py test_*.py *_tests.py
testpaths =
hypha
filterwarnings =
ignore::DeprecationWarning
ignore::PendingDeprecationWarning
[coverage:run]
plugins = django_coverage_plugin
omit =
*migrations*,
*test*
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment