Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/lint-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@ jobs:
run: uv sync --all-extras

- name: Run pytest
run: uv run pytest --cov=mitreattack
run: uv run --extra dev pytest -n 2 --cov=mitreattack
6 changes: 6 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
- Before committing, run `just lint`.
- `just lint`: run pre-commit hooks across the repo.
- `just test`: run the pytest suite.
- `just test-xdist`: run the pytest suite in parallel.
- `just test-cov`: run tests with coverage for `mitreattack`.
- `just test-cov-xdist`: run tests with coverage in parallel.
- `just build`: build distributions with `uv build`.
- Without `just`, run the same tools through `uv run ...`.

Expand All @@ -32,6 +34,10 @@
- Framework: `pytest` (with `pytest-cov` for coverage checks).
- Place tests under `tests/` and name files/functions `test_*.py` / `test_*`.
- Add or update tests for behavior changes, especially around STIX parsing and changelog/diff output paths.
- Tests that need real ATT&CK STIX data should use the shared STIX fixtures instead of downloading or
preparing bundles directly.
- Parallel runs warm the shared STIX cache before workers start; update `DEFAULT_ATTACK_STIX_PREP` in
`tests/conftest.py` if a new xdist-backed test needs another ATT&CK release.
- Run `just test` locally before opening a PR; use `just test-cov` for larger changes.

## Commit & Pull Request Guidelines
Expand Down
36 changes: 0 additions & 36 deletions conftest.py

This file was deleted.

7 changes: 7 additions & 0 deletions docs/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,17 @@ Run `just` with no arguments to see all available commands. Here are the most co
```bash
just lint # Run pre-commit hooks (ruff format) on all files
just test # Run tests
just test-xdist # Run tests in parallel
just test-cov # Run tests with coverage report
just test-cov-xdist # Run tests with coverage in parallel
just build # Build the package
```

Tests that need real ATT&CK STIX data should use the shared STIX fixtures instead of downloading or
preparing bundles directly. Parallel test runs warm the shared STIX cache before workers start; if a
new xdist-backed test needs an additional ATT&CK release, update the cache warmup list in
`tests/conftest.py`.

To run STIX-backed tests against specific local bundles, pass the bundle paths to pytest:

```bash
Expand Down
8 changes: 8 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ ruff-format:
test:
uv run pytest

# Run tests in parallel
test-xdist workers="auto":
uv run --extra dev pytest -n {{ workers }}

# Run tests with coverage in parallel
test-cov-xdist workers="auto":
uv run --extra dev pytest -n {{ workers }} --cov=mitreattack

# Run tests with coverage
test-cov:
uv run pytest --cov=mitreattack
Expand Down
5 changes: 5 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ dev = [
"pytest>=8.4.2",
"pytest-cov>=7.0.0",
"pytest-dotenv>=0.5.2",
"pytest-xdist>=3.8.0",
"python-semantic-release>=10.5.0",
"responses>=0.25.8",
"ruff>=0.14.2",
Expand Down Expand Up @@ -131,3 +132,7 @@ version_files = [
"docs/conf.py:^release = ['\"](.*)['\"]",
"mitreattack/__init__.py:^__version__ = ['\"](.*)['\"]",
]

[[tool.uv.index]]
url = "https://pypi.org/simple"
default = true
4 changes: 2 additions & 2 deletions tests/changelog/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -1594,10 +1594,10 @@ def golden_161_170_changelog_dir():


@pytest.fixture(scope="session")
def generated_161_170_diffstix(tmp_path_factory) -> DiffStix:
def generated_161_170_diffstix() -> DiffStix:
"""Create and cache a DiffStix instance for reuse across tests."""
versions_param = ["16.1", "17.0"]
result_paths = _download_attack_stix_data(versions_param, tmp_path_factory)
result_paths = _download_attack_stix_data(versions_param)
return DiffStix(
domains=["enterprise-attack", "mobile-attack", "ics-attack"],
old=result_paths["16.1"],
Expand Down
Loading
Loading