Skip to content

Commit

Permalink
Add pytest-cov for unit-test coverage (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
vdusek authored Dec 21, 2023
1 parent 659bf80 commit 6ce4e7d
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 6 deletions.
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,14 @@ __pycache__
*.egg
dist/
build/
.coverage
htmlcov

.vscode
.idea
.DS_Store

docs/changelog.md

# default folder for memory storage data
storage/
28 changes: 23 additions & 5 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,33 @@ and [direnv](https://github.com/direnv/direnv) to automatically activate/deactiv

## Dependencies

To install this package and its development dependencies, run `make install-dev`
To install this package and its development dependencies, run `make install-dev`.

## Formatting
## Code checking

We use `ruff` to automatically format the code to a common format. To run the formatting, just run `make format`.
To run all our code checking tools together, just run `make check-code`.

## Linting, type-checking and unit testing
### Linting

We use `ruff` for linting, `mypy` for type checking and `pytest` for unit testing. To run these tools, just run `make check-code`.
We use [ruff](https://docs.astral.sh/ruff/) for linting to to analyze the code for potential issues and enforce
uniformed code style. See the `pyproject.toml` for its configuration. To run the linting, just run `make lint`.

### Formatting

We use [ruff](https://docs.astral.sh/ruff/) for automated code formatting. It formats the code to follow uniformed
code style and addresses auto-fixable linting issues. See the `pyproject.toml` for its configuration. To run
the formatting, just run `make format`.

### Type checking

We use [mypy](https://mypy.readthedocs.io/en/stable/) for type checking. See the `mypy.ini` for its configuration.
To run the type checking, just run `make type-check`.

### Unit tests

We use [pytest](https://docs.pytest.org/) as a testing framework with many plugins. See the `pyproject.toml` for
both its configuration and the list of installed plugins. To run unit tests execute `make unit-tests`. To run unit
tests with HTML coverage report execute `make unit-tests-cov`.

## Release process

Expand Down
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ lint:
python3 -m ruff check $(DIRS_WITH_CODE)

unit-tests:
python3 -m pytest -n auto -ra tests/unit
python3 -m pytest -n auto -ra tests/unit --cov=src/apify_shared

unit-tests-cov:
python3 -m pytest -n auto -ra tests/unit --cov=src/apify_shared --cov-report=html

type-check:
python3 -m mypy $(DIRS_WITH_CODE)
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ dev = [
"pydoc-markdown ~= 4.8.2",
"pytest ~= 7.4.2",
"pytest-asyncio ~= 0.21.0",
"pytest-cov ~= 4.1.0",
"pytest-only ~= 2.0.0",
"pytest-timeout ~= 2.2.0",
"pytest-xdist ~= 3.3.1",
Expand Down

0 comments on commit 6ce4e7d

Please sign in to comment.