test: reorganize suite by module under test and remove duplicates - #31
Merged
Conversation
Group tests by the unit they cover instead of by bug-fix batch: - add tests/conftest.py (autouse KONFAI env defaults, write_config and image_attributes fixtures), replacing 12 copy-pasted module-level os.environ.setdefault blocks that violated the monkeypatch rule - fold the audit/fixes grab-bags and single-test files into per-module files: config, patching, data_manager, transform, augmentation, network, blocks, schedulers, models, dataset, measure, main_cli - merge 5 duplicated tests into their surviving twin, keeping every assertion (config missing-file/invalid-yaml/invalid-literal errors, Data._split tail dedup) 38 unit files instead of 60; 343 -> 338 collected tests (the 5 exact duplicates); per-module coverage is byte-identical before/after.
- fold test_trainer_checkpoints/test_early_stopping/test_ema_convention/ test_resume_lr_override/test_resume_https_checkpoint into test_trainer.py and test_runtime_guards/test_runtime_progress_ddp into test_runtime.py, all tests moved verbatim (18 and 13 collected IDs unchanged) - fix the remaining ruff violations across tests/ (import order, unused noqa, ClassVar on mutable class defaults, zip strict, raw regex match) and reformat the flagged files - mark tests/integration with pytest.mark.integration so -m selection works
Extend ruff check/format targets with tests/ in the CI jobs and in both pixi task blocks so test-suite hygiene is gated like source code.
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
Reorganize
tests/unitfrom per-bugfix files into per-module files, without adding or losing any test behaviour: 60 → 38 unit files, net −460 lines, per-module coverage byte-identical before/after.What changed
tests/conftest.py: an autouse fixture sets the mandatoryKONFAI_config_file/KONFAI_CONFIG_MODEdefaults viamonkeypatch.setenv(per AGENTS.md §7), plus sharedwrite_configandimage_attributesfixtures. This removes the 12 copy-pasted module-levelos.environ.setdefaultblocks and their# noqa: E402trails.test_audit_fixes.py,test_*_fixes.py,test_*_audit.py,test_data_pipeline_audit.py) and single-test files are redistributed intotest_config.py,test_patching.py,test_data_manager.py,test_transform.py,test_augmentation.py,test_network.py,test_blocks.py,test_schedulers.py,test_models.py,test_dataset.py,test_measure.py,test_main_cli.py. Regression comments and AUDIT.md references are preserved.Literalerror (options-mentioned assertion kept)Data._splittail dedup (no-duplication/subset assertions folded into the shard-balance test)Verification
konfaisource in the same env — the--cov=konfaitable is identical line-for-line, module-by-module (8844 stmts, 3254 miss, 63%), proving the removed tests covered no unique line.ruff check/formatclean on every touched file (pre-existing violations in untouched files left as-is).No test was added and none weakened; built-in measures/models intentionally stay untested as agreed.
Follow-up commits
test:merge the trainer-related files (test_trainer_checkpoints/test_early_stopping/test_ema_convention/test_resume_lr_override/test_resume_https_checkpoint→test_trainer.py) and the runtime files (test_runtime_guards/test_runtime_progress_ddp→test_runtime.py) — all 31 tests moved verbatim, collected IDs unchanged; fix every remaining ruff violation intests/and wirepytest.mark.integrationso-mselection works.ci:gate the core test suite in ruff: the CI lint/format jobs and both pixi task blocks now targetkonfai konfai-apps/konfai_apps tests.Final state: 36 unit files (was 60),
ruff check/format --checkclean over the whole repo including tests, 338 tests passing.