Skip to content

Introduce helper fixtures and pytest assertions - #71

Closed
blalterman wants to merge 1 commit into
update-2025from
codex/2025-07-24-t-14-30-33-refactor-testbase-to-use-fixtures-and-pytest
Closed

Introduce helper fixtures and pytest assertions#71
blalterman wants to merge 1 commit into
update-2025from
codex/2025-07-24-t-14-30-33-refactor-testbase-to-use-fixtures-and-pytest

Conversation

@blalterman

Copy link
Copy Markdown
Owner

Summary

  • provide common data fixtures in test_base
  • use bare assertions in TestQuantitySubclassEquality

Testing

  • flake8 solarwindpy/tests/test_base.py solarwindpy/tests/test_quantities.py
  • black solarwindpy/tests/test_base.py solarwindpy/tests/test_quantities.py -q
  • pytest solarwindpy/tests/test_quantities.py::TestQuantitySubclassEquality::test_v -q

https://chatgpt.com/codex/tasks/task_e_6881c38bd26c832ca3425d9680214435

@blalterman
blalterman deleted the codex/2025-07-24-t-14-30-33-refactor-testbase-to-use-fixtures-and-pytest branch August 12, 2025 12:33
blalterman added a commit that referenced this pull request Jan 9, 2026
- Regenerate docs/requirements.txt with urllib3 security fix
- Regenerate requirements-dev.lock with security fix + new deps
- Adds ast-grep-py and pre-commit to dev lockfile
Resolves dependabot alert #71 (decompression bomb vulnerability)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
blalterman added a commit that referenced this pull request Jan 9, 2026
* feat(copilot): add automated check hooks
Add hook integration tests validating:
- Hook chain execution order (SessionStart → Stop)
- settings.json configuration for all lifecycle events
- Hook script existence and functionality
- Definition of Done pattern enforcement
- Test-runner modes for physics and coverage validation
Tests verify existing hook infrastructure without requiring
actual file edits or git operations.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* feat(copilot): add implement and fix-tests commands
Add Core Dev Loop slash commands:
- /swp:dev:implement - Guided feature/fix implementation
- Analysis, planning, and execution phases
- Physics validation for core/instabilities modules
- Hook-based Definition of Done pattern
- /swp:dev:fix-tests - Guided test failure recovery
- 6 failure categories with targeted fixes
- DataFrame pattern recovery guide
- Physics constraint validation
Both commands leverage existing hooks as validation layer.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* feat(copilot): add DataFrame patterns audit workflow
Add DataFrame patterns tooling:
- /swp:dev:dataframe-audit - Audit command for M/C/S patterns
- dataframe-patterns.yml - ast-grep rules (advisory mode)
- swp-df-001: Prefer .xs() over boolean indexing
- swp-df-002: Chain reorder_levels with sort_index
- swp-df-003: Use transpose-groupby pattern
- swp-df-004: Validate MultiIndex names
- swp-df-005: Check duplicate columns
- swp-df-006: Level parameter usage
- test_contracts_dataframe.py - 23 contract tests covering:
- MultiIndex structure validation (M/C/S names, 3 levels)
- Ion data requirements (M/C names, required columns)
- Cross-section patterns (.xs() usage)
- Reorder levels + sort_index chain
- Groupby transpose pattern
- Column duplication prevention
- Level-specific operations
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* feat(copilot): add class usage refactoring workflow
Add Class Usage slice:
- /swp:dev:refactor-class - Analyze and refactor class patterns
- Class hierarchy documentation (Core → Base → Plasma/Ion/etc)
- Constructor validation patterns
- Species handling rules
- class-patterns.yml - ast-grep rules (advisory mode)
- swp-class-001: Plasma constructor requires species
- swp-class-002: Ion constructor requires species
- swp-class-003: Spacecraft requires name and frame
- swp-class-004: xs() should specify axis and level
- swp-class-005: super().__init__() pattern
- swp-class-006: Plasma attribute access via __getattr__
- test_contracts_class.py - 35 contract tests covering:
- Class hierarchy inheritance
- Core/Base class initialization (logger, units, constants)
- Ion class requirements and data extraction
- Plasma class species handling and Ion creation
- Vector and Tensor class structure
- Constructor validation contracts
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* feat(copilot): integrate ast-grep with grep fallback for pattern detection
- Update /swp:dev:dataframe-audit to use `sg scan --config` as primary method
- Update /swp:dev:refactor-class with ast-grep validation section
- Fix ast-grep YAML rules to use `rule:` block with `$$$args` syntax
- Add installation instructions for ast-grep (brew/pip/cargo)
- Document grep fallback for patterns ast-grep can't handle
- Change rule severity from warning to info (advisory mode)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* chore(deps): add ast-grep-py and pre-commit to dev dependencies
- ast-grep-py>=0.35: Structural code pattern matching for /swp:dev:* commands
- pre-commit>=3.5: Git hook framework (was missing from dev deps)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* fix(deps): update urllib3 to 2.6.3 for CVE-2026-21441
- Regenerate docs/requirements.txt with urllib3 security fix
- Regenerate requirements-dev.lock with security fix + new deps
- Adds ast-grep-py and pre-commit to dev lockfile
Resolves dependabot alert #71 (decompression bomb vulnerability)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* fix(deps): add pip-to-conda name translations and pip-only exclusions
- Add translations: blosc2→python-blosc2, msgpack→msgpack-python,
mypy-extensions→mypy_extensions, restructuredtext-lint→restructuredtext_lint
- Add PIP_ONLY_PACKAGES set for packages not on conda-forge (ast-grep-py)
- Regenerate solarwindpy.yml from requirements-dev.lock with all dev deps
- Update header to mention pip-only packages and recommend pip install -e ".[dev]"
This fixes conda env creation failures when packages have different names
on PyPI vs conda-forge, or are pip-only.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* feat(deps): add pip-only packages to conda yml pip: subsection
Instead of excluding pip-only packages (like ast-grep-py), add them to
a `pip:` subsection in the generated solarwindpy.yml. This allows
single-step environment creation:
conda env create -f solarwindpy.yml # Installs everything
pip install -e . # Just editable install
The pip: subsection is automatically populated from PIP_ONLY_PACKAGES
and installed by conda during env creation.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* refactor(deps): remove ast-grep-py, use MCP server instead
- Remove ast-grep-py from dev dependencies in pyproject.toml
- ast-grep functionality now provided via MCP server (@ast-grep/ast-grep-mcp)
- Clear PIP_ONLY_PACKAGES set (no pip-only packages currently needed)
- Regenerate requirements-dev.lock and solarwindpy.yml
The MCP server provides Claude-native ast-grep access, eliminating the
need for Python bindings. Install MCP server with:
claude mcp add ast-grep -- npx -y @ast-grep/ast-grep-mcp
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@blalterman