Skip to content

Conversation

@federetyk
Copy link
Contributor

Link to issue: #25

Description

Fixed the AttributeError in test_evaluate_multiple_models.py caused by incorrect mock patching

The issue: patch("workrb.evaluate.evaluate") fails because workrb.evaluate resolves to the evaluate function (exported in __init__.py) rather than the module, causing Python to look for an evaluate attribute on the function object

Solution: Use patch.object() with an explicitly imported module reference to ensure the correct target is patched

Changes:

  • Added import importlib
  • Added evaluate_module = importlib.import_module("workrb.evaluate") to get explicit module reference
  • Replaced all patch("workrb.evaluate.evaluate") with patch.object(evaluate_module, "evaluate")

Checklist

  • Added new tests for new functionality
  • Tested locally with example tasks
  • Code follows project style guidelines
  • Documentation updated
  • No new warnings introduced

@Mattdl Mattdl self-requested a review January 6, 2026 15:36
@Mattdl Mattdl added the bug Something isn't working label Jan 6, 2026
@federetyk
Copy link
Contributor Author

Superseded by a cleaner fix: renaming the module to avoid the naming collision entirely. See this comment and #29

@federetyk federetyk closed this Jan 6, 2026
@federetyk federetyk deleted the fix/test-evaluate-patch-attribute-error branch January 6, 2026 18:08
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.

2 participants