Skip to content

Commit 5a37eaf

Browse files
committed
test: Настройка отображения покрытия кода
1 parent 52ef4e0 commit 5a37eaf

File tree

3 files changed

+48
-0
lines changed

3 files changed

+48
-0
lines changed

.github/workflows/test_runner.yaml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout repository
15+
uses: actions/checkout@v2
16+
17+
- name: Set up Python
18+
uses: actions/setup-python@v2
19+
with:
20+
python-version: "3.11"
21+
22+
- name: Install Poetry
23+
run: |
24+
pip install poetry
25+
26+
- name: Install dependencies
27+
run: |
28+
poetry install
29+
30+
- name: Run tests
31+
run: |
32+
pytest --cov=./ --cov-report=xml
33+
34+
- name: Upload coverage to Codecov
35+
uses: codecov/codecov-action@v1
36+
with:
37+
token: ${{ secrets.CODECOV_TOKEN }} # Token для авторизации, его надо добавить в secrets репозитория

pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ loguru = "^0.7.3"
3636
ipykernel = "^6.19.4"
3737
pre-commit = "^3.6.0"
3838
ruff = "^0.11.0"
39+
pytest-cov = "^6.1.1"
40+
codecov = "^2.1.13"
3941

4042
[build-system]
4143
requires = ["poetry-core"]

tests/test_file1.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import pytest
2+
3+
4+
@pytest.mark.parametrize(
5+
'test_input,expected',
6+
[('3+5', 8), ('2+4', 6), pytest.param('6*9', 42, marks=pytest.mark.xfail)],
7+
)
8+
def test_eval(test_input, expected):
9+
assert eval(test_input) == expected

0 commit comments

Comments
 (0)