Repository navigation
Add comprehensive testing & quality assurance infrastructure (v5.2.0) - #10
Merged
Merged
Conversation
Adds production-grade reliability infrastructure: * Property-based tests (test_property_based.py): 27 Hypothesis tests verifying Dimension forms an Abelian group, power laws hold, unit conversion is symmetric, and physics formulas (F=ma, v=d/t, E=Fd) produce correct dimensions. * Fuzz tests (test_fuzz.py): 16 tests with adversarial JSON, NaN/inf data, and random operation sequences. Asserts only documented exception types are raised. * Chaos tests (test_chaos.py): 20 tests for graceful degradation (missing files, corrupt JSON, optional dependencies, concurrent reads, ill-formed serialized data). * Load tests (test_load.py): 9 stress tests with generous time budgets to catch O(n^2) regressions on million-element arrays. * Mutation testing (.mutmut.toml): mutmut config scoped to core modules so mutation runs are tractable. * Coverage dashboard (.github/workflows/dimtensor-coverage.yml): Codecov upload, HTML report artifact, badge JSON, PR comments. * Security audit (.github/workflows/dimtensor-security.yml): Bandit (SAST), pip-audit, Safety, Trivy, CodeQL. Weekly schedule plus on-PR runs. * New [test] optional dependency group covering hypothesis, mutmut, bandit, safety, pip-audit. * New docs/guide/testing.md describing every layer. * Fixes version mismatch: __init__.py was 5.1.0, pyproject.toml was 5.2.0; both are now 5.2.0. 184 core+new tests pass, 0 regressions. https://claude.ai/code/session_01C5HKiidr4gE4dqDqrZtHMZ
|
You are seeing this message because GitHub Code Scanning has recently been set up for this repository, or this pull request contains the workflow file for the Code Scanning tool. What Enabling Code Scanning Means:
For more information about GitHub Code Scanning, check out the documentation. |
Benchmark Results
Average overhead: 4.52x 📊 Full benchmark results are available in the workflow artifacts. |
Dimensional Linting Results
|
☂️ Python Coverage
Overall Coverage
New FilesNo new covered files... Modified Files
|
|
|
||
| from __future__ import annotations | ||
|
|
||
| import io |
|
|
||
| import io | ||
| import json | ||
| import sys |
| import io | ||
| import json | ||
| import sys | ||
| import tempfile |
| import sys | ||
| import tempfile | ||
| from pathlib import Path | ||
| from unittest.mock import patch |
| import numpy as np | ||
| import pytest | ||
|
|
||
| from dimtensor import DimArray, Dimension, Unit, units |
| """Garbage JSON strings must raise an allowed exception type.""" | ||
| try: | ||
| from_json(text) | ||
| except ALLOWED_EXCEPTIONS + (json.JSONDecodeError,): |
| """Random dicts: from_dict must raise an allowed exception.""" | ||
| try: | ||
| from_dict(payload) | ||
| except ALLOWED_EXCEPTIONS: |
| try: | ||
| recovered = from_dict(d) | ||
| assert recovered.unit.symbol == garbage_symbol | ||
| except ALLOWED_EXCEPTIONS: |
| """unit * scalar should always work or raise an allowed exception.""" | ||
| try: | ||
| _ = unit * scalar | ||
| except ALLOWED_EXCEPTIONS: |
| import numpy as np | ||
| import pytest | ||
|
|
||
| from dimtensor import DimArray, Dimension, Unit, units |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR introduces production-grade testing and quality assurance infrastructure for dimtensor, adding 72 new tests across four complementary testing layers plus security scanning and coverage reporting workflows.
Key Changes
Testing Infrastructure
Property-based tests (
tests/test_property_based.py, 27 tests):a**p * a**q == a**(p+q),(a**p)**q == a**(p*q))Fuzz tests (
tests/test_fuzz.py, 16 tests):Chaos tests (
tests/test_chaos.py, 20 tests):Load tests (
tests/test_load.py, 9 tests):Quality Assurance Workflows
Coverage dashboard (
.github/workflows/dimtensor-coverage.yml):Security audit (
.github/workflows/dimtensor-security.yml):Configuration & Documentation
Mutation testing (
.mutmut.toml):src/dimtensor/core/for focused mutation analysisTest markers (pyproject.toml):
slow: for expensive tests (deselectable)network: for tests requiring network accessload: for stress testsCoverage configuration (pyproject.toml):
Testing guide (
docs/guide/testing.md):Dependencies
[test]extras group: hypothesis, mutmut, pytest-cov, coverage, bandit, safety, pip-auditVersion Update
__version__to "5.2.0" insrc/dimtensor/__init__.pyImplementation Details
Test Strategy: The four-layer approach provides complementary coverage:
**Exception Safety
https://claude.ai/code/session_01C5HKiidr4gE4dqDqrZtHMZ