Skip to content

fix(tests): stub pymongo so the suite collects without a driver installed - #536

Merged
robsv merged 1 commit into
mainfrom
fix-ci-pymongo-stub
Oct 7, 2026
Merged

robsv merged 1 commit into
mainfrom
fix-ci-pymongo-stub

Conversation

@robsv

@robsv robsv commented Oct 7, 2026

Copy link
Copy Markdown
Collaborator

tests/test_name_maintenance.py imports fix_middle_names, which imports pymongo. CI installs pytest, jrc_common and doi_common only, so collection failed outright:

ERROR collecting tests/test_name_maintenance.py
ModuleNotFoundError: No module named 'pymongo'

That took the whole suite down, not just the new file - a collection error is fatal, so the 94 pre-existing tests never ran either. Both interpreters have been failing since the maintenance programs landed.

The stub carries a real exception class rather than a bare module. Both maintenance programs catch pymongo.errors.PyMongoError, and an except clause naming something that is not an exception class raises TypeError when it is reached - which would turn a database error into a confusing failure three frames from its cause. Nothing here exercises that path today, so the mistake would have sat unnoticed until it mattered.

Verified in a virtual environment built to match the workflow exactly - pytest plus the two git-installed libraries, no pymongo, no tqdm, no jrc_email. 113 tests pass there, and the stub is confirmed to be the module actually in use.

…lled

tests/test_name_maintenance.py imports fix_middle_names, which imports
pymongo. CI installs pytest, jrc_common and doi_common only, so collection
failed outright:

  ERROR collecting tests/test_name_maintenance.py
  ModuleNotFoundError: No module named 'pymongo'

That took the whole suite down, not just the new file - a collection error
is fatal, so the 94 pre-existing tests never ran either. Both interpreters
have been failing since the maintenance programs landed.

The stub carries a real exception class rather than a bare module. Both
maintenance programs catch pymongo.errors.PyMongoError, and an except clause
naming something that is not an exception class raises TypeError when it is
reached - which would turn a database error into a confusing failure three
frames from its cause. Nothing here exercises that path today, so the
mistake would have sat unnoticed until it mattered.

Verified in a virtual environment built to match the workflow exactly -
pytest plus the two git-installed libraries, no pymongo, no tqdm, no
jrc_email. 113 tests pass there, and the stub is confirmed to be the module
actually in use.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@robsv robsv self-assigned this Oct 7, 2026
@robsv robsv added the bug Something isn't working label Oct 7, 2026
@robsv
robsv merged commit b7029c4 into main Oct 7, 2026
2 checks passed
@robsv
robsv deleted the fix-ci-pymongo-stub branch October 7, 2026 16:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant