Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[run]
omit =
*/tests/*

[report]
exclude_lines =
if TYPE_CHECKING:
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,8 @@ nose2-junit.xml

# Node modules
node_modules/*

# Coverage
.coverage*
coverage.xml
htmlcov
13 changes: 13 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ PYTHON := $(PIPENV_RUN) python3
YAPF := $(PIPENV_RUN) yapf
ISORT := $(PIPENV_RUN) isort
PYLINT := $(PIPENV_RUN) pylint
PYTEST := DEBUG=True PYTHONPATH=app DJANGO_SETTINGS_MODULE=config.settings_test $(PIPENV_RUN) pytest

# Set summon only if not already set, this allow to disable summon on environment
# that don't use it like for CodeBuild env
Expand Down Expand Up @@ -216,6 +217,18 @@ test-conformance:
--geometry '{"type": "Polygon", "coordinates": [[[0, 0], [90, 0], [90, 90], [0, 90], [0, 0]]]}' \
--collection $(collection)

.PHONY: test-coverage
test-coverage:
# Collect static first to avoid warning in the test
$(PYTHON) $(DJANGO_MANAGER) collectstatic --noinput
$(PYTEST) -n 20 --cov --cov-report=html

.PHONY: test-ci
test-ci:
# Collect static first to avoid warning in the test
$(PYTHON) $(DJANGO_MANAGER) collectstatic --noinput
$(PYTEST) -n 20 --cov --cov-report=xml
Comment on lines +226 to +230
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you also intend to update the CI ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, as soon as this is merged I'll create a PR


###################
# Specs
.PHONY: build-specs
Expand Down
1 change: 1 addition & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ pytest = "*"
pytest-django = "*"
pytest-dotenv = "*"
pytest-cov = "*"
pytest-xdist = "*"

[packages]
gevent = "~=25.4.1"
Expand Down
463 changes: 248 additions & 215 deletions Pipfile.lock

Large diffs are not rendered by default.

14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ Alternatively you can use `make` to run the tests which will run all tests in pa
make test
```

or use the container environment like on the CI.
Or use the container environment like on the CI.

```bash
docker compose -f docker-compose-ci.yml up --build --abort-on-container-exit
Expand All @@ -254,6 +254,18 @@ docker compose -f docker-compose-ci.yml up --build --abort-on-container-exit
**NOTE:** the `--build` option is important otherwise the container will not be rebuild and you don't have the latest modification
of the code.

Or use pytest. Either directly in Visual Studio Code via the `ms-python.python` extension or with the CLI:

```
pytest -k test_pgtrigger_file_size
```

Or generate a coverage report:

```
make test-coverage
```

#### Unit test logging

By default only `WARNING` logs of the `tests` module is printed in the console during unit testing.
Expand Down
4 changes: 4 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
[pytest]
pythonpath = app

DJANGO_SETTINGS_MODULE= app.config.settings_test

addopts = --ds=config.settings_test

django_debug_mode = true

python_files = test_*.py
Expand Down
Loading