-
Notifications
You must be signed in to change notification settings - Fork 773
Open
Description
Describe the bug
Running the test suite on macOS with Python 3.12 causes an INTERNALERROR in
tests/unit/test_mlflow_manager.py due to the use of:
__builtins__.__import__
In Python 3.12 on macOS, __builtins__ is a dict, not a module, so it has no __import__ attribute.
This causes pytest to crash during test collection.
After replacing it with builtins.__import__ (which always exists), the INTERNALERROR disappears, but the test test_mlflow_manager_enabled_no_mlflow_package then fails normally — which is expected and indicates that the underlying logic can now be tested correctly.
Environment
• OS: macOS (Apple Silicon)
• Python: 3.12.x
• ROMA: main branch (commit: <paste your git rev-parse HEAD here>)
• Install: pip install -e ".[api]" in a fresh virtualenv
Steps to reproduce
git clone https://github.com/sentient-agi/ROMA.git
cd ROMA
python3.12 -m venv .venv
source .venv/bin/activate
pip install --upgrade pip
pip install -e ".[api]"
pytest tests/unit/test_mlflow_manager.py -q
Actual behavior
Pytest crashes with:
AttributeError: 'dict' object has no attribute '__import__'
File "tests/unit/test_mlflow_manager.py", line 50, in mock_import
return __builtins__.__import__(name, *args, **kwargs)
Expected behavior
The test should not cause an INTERNALERROR.
It should fail or pass normally depending on the logic being tested.
Proposed fix
Replace __builtins__.__import__ with builtins.__import__, which is stable across environments.
Example patch:
import builtins
_real_import = builtins.__import__
def mock_import(name, *args, **kwargs):
if name == "mlflow":
raise ImportError("mlflow not installed")
return _real_import(name, *args, **kwargs)Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels