Skip to content

Commit b2ce674

Browse files
Command for code coverage, remove useless code (#103)
* Remove useless compilation code * Remove useless pyproject.toml sections * Test coverage command
1 parent d160d2c commit b2ce674

6 files changed

Lines changed: 16 additions & 360 deletions

File tree

poetry.lock

Lines changed: 2 additions & 74 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ betterproto2-rust-codec = { version = "^0.1.2", optional = true }
3939
[tool.poetry.group.dev.dependencies]
4040
mypy = "^1.11.2"
4141
pre-commit = "^2.17.0"
42-
tox = "^4.0.0"
4342
mkdocs-material = {version = "^9.5.49", python = ">=3.10"}
4443
mkdocstrings = {version = "^0.27.0", python = ">=3.10", extras = ["python"]}
4544
# The Ruff version is pinned. To update it, also update it in .pre-commit-config.yaml
@@ -97,6 +96,10 @@ shell = "rm -r tests/output_* && cp -r ../python-betterproto2-compiler/tests/out
9796
cmd = "pytest"
9897
help = "Run tests"
9998

99+
[tool.poe.tasks.test-cov]
100+
cmd = "pytest --cov=betterproto2 --cov-report=term --cov-report=html tests/"
101+
help = "Run tests with code coverage report"
102+
100103
[tool.poe.tasks.typecheck]
101104
cmd = "pyright src"
102105
help = "Typecheck the code with Pyright"
@@ -148,32 +151,6 @@ help = "Pulls the compiled test files from the betterproto2-compiler repository"
148151
cmd = "mkdocs serve"
149152
help = "Serve the documentation locally"
150153

151-
# CI tasks
152-
153-
[tool.poe.tasks.full-test]
154-
shell = "poe generate && tox"
155-
help = "Run tests with multiple pythons"
156-
157-
[tool.tox]
158-
legacy_tox_ini = """
159-
[tox]
160-
requires =
161-
tox>=4.2
162-
tox-poetry-installer[poetry]==1.0.0b1
163-
env_list =
164-
py311
165-
py38
166-
py37
167-
168-
[testenv]
169-
commands =
170-
pytest {posargs: --cov betterproto}
171-
poetry_dep_groups =
172-
test
173-
require_locked_deps = true
174-
require_poetry = true
175-
"""
176-
177154
[build-system]
178155
requires = ["poetry-core>=2.0.0,<3"]
179156
build-backend = "poetry.core.masonry.api"

tests/conftest.py

Lines changed: 0 additions & 11 deletions
This file was deleted.

tests/generate.py

Lines changed: 0 additions & 171 deletions
This file was deleted.

tests/test_inputs.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import copy
12
import importlib
23
import json
34
import math
@@ -12,12 +13,7 @@
1213
import betterproto2
1314
from tests.inputs import config as test_input_config
1415
from tests.mocks import MockChannel
15-
from tests.util import (
16-
find_module,
17-
get_directories,
18-
get_test_case_json_data,
19-
inputs_path,
20-
)
16+
from tests.util import find_module, get_directories, get_test_case_json_data, inputs_path
2117

2218
# Force pure-python implementation instead of C++, otherwise imports
2319
# break things because we can't properly reset the symbol database.
@@ -113,6 +109,13 @@ def dict_replace_nans(input_dict: dict[Any, Any]) -> dict[Any, Any]:
113109
return result
114110

115111

112+
@pytest.fixture
113+
def reset_sys_path():
114+
original = copy.deepcopy(sys.path)
115+
yield
116+
sys.path = original
117+
118+
116119
@pytest.fixture
117120
def test_data(request, reset_sys_path):
118121
test_case_name = request.param

0 commit comments

Comments
 (0)