test: add tests to have a full coverage#207
Conversation
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #207 +/- ##
===========================================
+ Coverage 80.67% 99.88% +19.20%
===========================================
Files 13 13
Lines 1770 1699 -71
===========================================
+ Hits 1428 1697 +269
+ Misses 342 2 -340 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
b27716e to
d7812b1
Compare
d7812b1 to
42c9c4e
Compare
e343190 to
c782627
Compare
c782627 to
6dfd2fb
Compare
6dfd2fb to
9991d62
Compare
9991d62 to
2c5fe23
Compare
3b00113 to
ead694b
Compare
There was a problem hiding this comment.
Pull request overview
This PR restructures and significantly expands the test suite to drive higher coverage and make regressions easier to catch, while also adding new testing/benchmarking dependencies and a few small coverage-annotation changes in the library code.
Changes:
- Reorganized tests into
unit/,integration/,property/, andbenchmarks/suites with collection markers. - Added extensive new unit + property-based coverage for core modules (server, download, safe_zip, config, match, language tag, CLI).
- Added test tooling/dependencies (
hypothesis,pytest-benchmark) and minor CI/dev-experience tweaks (markers,--basetemp,cleantarget).
Reviewed changes
Copilot reviewed 45 out of 47 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| uv.lock | Locks new test dependencies (hypothesis, pytest-benchmark) and their transitive deps. |
| pyproject.toml | Adds new test deps; expands Ruff per-file ignores; adds mypy override for Hypothesis-heavy tests. |
| pytest.ini | Adds markers and sets project-local --basetemp for tmp dirs. |
| .github/workflows/test.yml | CI matrix tweak (Python 3.15 beta version bump); continues running pytest in CI. |
| Makefile | Adds clean target; makes publish run clean first; updates usage output. |
| make.bat | Adds clean target and wires publish through it; updates usage output. |
| .gitignore | Ignores .pytest_tmp/ (the new --basetemp directory). |
| src/language_tool_python/server.py | Adds coverage annotation for an effectively-unreachable branch in response decoding. |
| src/language_tool_python/language_tag.py | Enhances docstring parameter documentation. |
| src/language_tool_python/download_lt.py | Adds pragma: no cover to abstract/unreachable paths; annotates some TOCTOU-only branches. |
| src/language_tool_python/config_file.py | Adds pragma: no cover and explanation for hard-to-create path types. |
| src/language_tool_python/_internals/safe_zip.py | Annotates TOCTOU/defensive branches and refines coverage pragmas. |
| src/language_tool_python/_internals/compat.py | Marks version-specific fallback imports as not coverable in the coverage environment. |
| src/language_tool_python/main.py | Adds defensive coverage pragmas and annotates main guard. |
| tests/unit/init.py | Declares unit test package. |
| tests/unit/conftest.py | Automatically applies the unit marker to tests under tests/unit/. |
| tests/unit/test_api_types.py | Adds unit tests for API response type-guard helpers. |
| tests/unit/test_cli_args.py | Adds focused unit tests for CLI argument parsing edge cases. |
| tests/unit/test_cli_unit.py | Adds unit tests for CLI helpers (get_text, stdin handling, main status aggregation, etc.). |
| tests/unit/test_config_unit.py | Adds unit tests for config encoding/validation and LanguageToolConfig behavior. |
| tests/unit/test_config_validation.py | Adds targeted unit tests for injection/backslash protections in config serialization. |
| tests/unit/test_download.py | Refactors download tests to avoid module reloads; adds more HTTP error-path tests. |
| tests/unit/test_download_unit.py | Adds unit-level tests for download_lt.py helpers and version logic without network/Java. |
| tests/unit/test_internals_utils.py | Adds unit tests for internal helpers like env parsing, locale fallback, psutil killing, version parsing. |
| tests/unit/test_language_tag.py | Adds unit tests for LanguageTag normalization, fallback behavior, and comparisons. |
| tests/unit/test_match.py | Adds unit tests for Match construction, formatting, comparison, iteration, and helper functions. |
| tests/unit/test_safe_zip.py | Refactors to tmp_path; adds more fine-grained safe-zip unit tests (incl. internal helpers). |
| tests/unit/test_server_unit.py | Adds extensive isolated unit tests for server logic (no Java/network required). |
| tests/unit/test_utils.py | Adds unit tests for classify_matches, correct, and TextStatus enum values. |
| tests/test_api_public.py (deleted) | Removes old public-API test; superseded by tests/integration/test_api_public.py. |
| tests/property/init.py | Declares property test package. |
| tests/property/conftest.py | Automatically applies the property marker to tests under tests/property/. |
| tests/property/test_prop_config.py | Adds Hypothesis tests for config invariants and schema behaviors. |
| tests/property/test_prop_language_tag.py | Adds Hypothesis tests for LanguageTag normalization/ordering invariants. |
| tests/property/test_prop_safe_zip.py | Adds Hypothesis adversarial tests for path traversal protections in safe zip handling. |
| tests/property/test_prop_utils.py | Adds Hypothesis tests for utility-function invariants (correct, classify_matches). |
| tests/integration/init.py | Declares integration test package. |
| tests/integration/conftest.py | Automatically applies the integration marker to tests under tests/integration/. |
| tests/integration/test_api_public.py | Adds more stable public API integration assertions (field-level vs full snapshot). |
| tests/integration/test_cli.py | Refactors CLI integration tests and helpers; uses public properties for host/port. |
| tests/integration/test_config.py | Improves caching timing test robustness; moves invalid-language test into integration. |
| tests/integration/test_download.py | Adds integration tests for real network download/version behaviors. |
| tests/integration/test_match.py | Updates integration match expectations to be less brittle re: typography. |
| tests/integration/test_server_local.py | Improves cleanup reliability and uses public accessors (host, port). |
| tests/benchmarks/init.py | Declares benchmarks package. |
| tests/benchmarks/conftest.py | Automatically applies the perf marker to tests under tests/benchmarks/. |
| tests/benchmarks/test_bench_check.py | Adds benchmark tests using pytest-benchmark for check/correct performance. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
0a0edfc to
c2bcc80
Compare
c2bcc80 to
644bfc8
Compare
test: add tests to have a full coverage
Why the pull request was made
To have a full coverage of the library, and easily detect bugs on future changes.
Summary of changes
benchmark,integration,property,unit.pytest-benchmarkandhypothesisas test dependencies.Screenshots (if appropriate):
Not applicable.
How has this been tested?
Applied tests.
Resources
Not applicable.
Types of changes
Checklist