Skip to content

Commit 1b4f7c5

Browse files
authored
Add exhaustive pytest test suite (240 tests, all modules) (#601)
* Add exhaustive pytest test suite with 240 tests covering all modules Comprehensive test coverage for a codebase that previously had zero tests: - 7 test files covering parsers (20 parsers), obfuscators (4), packers (2), planners (5), requirements (8), stockpile_svc, donut handler, and hook.py - Lightweight fake objects in conftest.py shim all Caldera internals so tests run standalone without a Caldera server - Config: pytest.ini, tox.ini, .pre-commit-config.yaml * Address Copilot review feedback on exhaustive pytest coverage - Replace all hardcoded /tmp/stockpile-pytest/ paths with repo-relative paths derived from Path(__file__).resolve().parents[1] - Fix shutil.which patch target in test_service.py to use patch.object on the loaded module (stockpile_svc imports via 'from shutil import which') - Replace fixed /tmp/ dirs in test_packers.py with pytest tmp_path fixture - Make base64_jumble randomness test deterministic by patching random.choice - Fix BaseParser.line shim in conftest to match real implementation (split on '\n', strip '\r', skip empty lines) - Use monkeypatch.setitem for sys.modules injection in test_hook.py - Move donut shim to a module-scoped autouse fixture in test_donut.py - Remove contradictory --ignore=E501 from .pre-commit-config.yaml flake8 config
1 parent c7d39a9 commit 1b4f7c5

13 files changed

+3131
-0
lines changed

.pre-commit-config.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v4.5.0
4+
hooks:
5+
- id: trailing-whitespace
6+
- id: end-of-file-fixer
7+
- id: check-yaml
8+
- id: check-added-large-files
9+
10+
- repo: https://github.com/psf/black
11+
rev: 24.2.0
12+
hooks:
13+
- id: black
14+
args: [--check, --diff]
15+
language_version: python3
16+
17+
- repo: https://github.com/PyCQA/flake8
18+
rev: 7.0.0
19+
hooks:
20+
- id: flake8
21+
args: [--max-line-length=120]

pytest.ini

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[pytest]
2+
testpaths = tests
3+
asyncio_mode = auto
4+
markers =
5+
asyncio: mark a test as an asyncio coroutine

tests/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)