Skip to content

test: rename oold.py to oold_test.py so its tests are collected - #147

Merged
LukasGold merged 1 commit into
mainfrom
fix/collect-oold-tests
Aug 28, 2026
Merged

test: rename oold.py to oold_test.py so its tests are collected#147
LukasGold merged 1 commit into
mainfrom
fix/collect-oold-tests

Conversation

@LukasGold

Copy link
Copy Markdown
Contributor

Renames tests/utils/oold.py to tests/utils/oold_test.py. One-line change, two effects.

The mishap

The file holds 6 real tests for osw.utils.oold, but was named after the module under test rather than after pytest's collection pattern. It matches neither test_*.py nor *_test.py, and the repo overrides no python_files, so pytest never collected it. Its 4 siblings in the same directory all use *_test.py.

The same name caused a second, louder problem. Neither tests/ nor tests/utils/ has an __init__.py, so pytest's default prepend import mode inserts tests/utils/ at sys.path[0]. A bare import oold then resolves to this file, a plain module with no __path__, instead of the installed oold package:

ModuleNotFoundError: No module named 'oold.utils'; 'oold' is not a package

Full-suite runs happened to survive this only by collection-order luck: a top-level tests/*.py file imports osw.* first, which caches the real oold in sys.modules, and the cache then short-circuits the poisoned path. Narrower runs got no such luck. On main:

$ pytest tests/utils/
ERROR tests/utils/templates_test.py
ERROR tests/utils/utils_test.py
ERROR tests/utils/workflow_test.py
3 errors

The fix

Rename to oold_test.py. The basename no longer collides with the installed package, which removes the sys.path shadow, and the file now matches the collection pattern, which enables its tests.

Result

  • 6 previously-uncollected tests now run in CI: test_deep_equal, test_unique_array, test_deep_merge, test_merge_jsonld_context_object_list, test_aggregate_generated_schemas, test_escape_json_strings
  • all 6 pass, no changes to their bodies were needed
  • full default suite: 36 passed -> 42 passed, 1 skipped
  • pytest tests/utils/ works for the first time: 29 passed, 1 skipped (was 3 collection errors)

Contents are unchanged; the diff is a pure rename (100% similarity).

- the filename matched neither test_*.py nor *_test.py, so its 6 tests
  had never been collected by pytest
- the basename also shadowed the installed oold package on sys.path,
  breaking `pytest tests/utils/` with "No module named 'oold.utils'"
- full default suite goes from 36 to 42 passed
@github-actions

Copy link
Copy Markdown
Contributor

Release preview

No version bump from the current commits (stays at v2.0.0). Use conventional commit types (feat, fix, ...) to trigger a release.

Changelog preview (truncated)

Preview via python-semantic-release and conventional commits.

@LukasGold
LukasGold merged commit 0d32bc2 into main Aug 28, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant