Skip to content

Commit 6ce4e7d

Browse files
authored
Add pytest-cov for unit-test coverage (#17)
1 parent 659bf80 commit 6ce4e7d

File tree

4 files changed

+35
-6
lines changed

4 files changed

+35
-6
lines changed

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,14 @@ __pycache__
1212
*.egg
1313
dist/
1414
build/
15+
.coverage
16+
htmlcov
1517

1618
.vscode
1719
.idea
1820
.DS_Store
21+
22+
docs/changelog.md
23+
24+
# default folder for memory storage data
25+
storage/

CONTRIBUTING.md

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,33 @@ and [direnv](https://github.com/direnv/direnv) to automatically activate/deactiv
2020

2121
## Dependencies
2222

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

25-
## Formatting
25+
## Code checking
2626

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

29-
## Linting, type-checking and unit testing
29+
### Linting
3030

31-
We use `ruff` for linting, `mypy` for type checking and `pytest` for unit testing. To run these tools, just run `make check-code`.
31+
We use [ruff](https://docs.astral.sh/ruff/) for linting to to analyze the code for potential issues and enforce
32+
uniformed code style. See the `pyproject.toml` for its configuration. To run the linting, just run `make lint`.
33+
34+
### Formatting
35+
36+
We use [ruff](https://docs.astral.sh/ruff/) for automated code formatting. It formats the code to follow uniformed
37+
code style and addresses auto-fixable linting issues. See the `pyproject.toml` for its configuration. To run
38+
the formatting, just run `make format`.
39+
40+
### Type checking
41+
42+
We use [mypy](https://mypy.readthedocs.io/en/stable/) for type checking. See the `mypy.ini` for its configuration.
43+
To run the type checking, just run `make type-check`.
44+
45+
### Unit tests
46+
47+
We use [pytest](https://docs.pytest.org/) as a testing framework with many plugins. See the `pyproject.toml` for
48+
both its configuration and the list of installed plugins. To run unit tests execute `make unit-tests`. To run unit
49+
tests with HTML coverage report execute `make unit-tests-cov`.
3250

3351
## Release process
3452

Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@ lint:
2323
python3 -m ruff check $(DIRS_WITH_CODE)
2424

2525
unit-tests:
26-
python3 -m pytest -n auto -ra tests/unit
26+
python3 -m pytest -n auto -ra tests/unit --cov=src/apify_shared
27+
28+
unit-tests-cov:
29+
python3 -m pytest -n auto -ra tests/unit --cov=src/apify_shared --cov-report=html
2730

2831
type-check:
2932
python3 -m mypy $(DIRS_WITH_CODE)

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ dev = [
3636
"pydoc-markdown ~= 4.8.2",
3737
"pytest ~= 7.4.2",
3838
"pytest-asyncio ~= 0.21.0",
39+
"pytest-cov ~= 4.1.0",
3940
"pytest-only ~= 2.0.0",
4041
"pytest-timeout ~= 2.2.0",
4142
"pytest-xdist ~= 3.3.1",

0 commit comments

Comments
 (0)