-
Notifications
You must be signed in to change notification settings - Fork 122
Open
Labels
Description
Issue Description
The test suite currently emits several warnings during pytest runs that, while not affecting functionality, are distracting and may indicate future compatibility issues.
Warnings Observed
1. pytest-asyncio Deprecation Warning
DeprecationWarning: The event_loop fixture provided by pytest-asyncio has been redefined in
/Users/andrew.brookins/src/redis-om-python/tests/conftest.py:20
Replacing the event_loop fixture with a custom implementation is deprecated
and will lead to errors in the future.
If you want to request an asyncio event loop with a scope other than function
scope, use the "scope" argument to the asyncio mark when marking the tests.
If you want to return different types of event loops, use the event_loop_policy
fixture.
2. Pydantic Field Shadowing Warning
UserWarning: Field name "dict" in "test_model_with_dict.<locals>.EmbeddedJsonModelWithDict" shadows an attribute in parent "EmbeddedJsonModel"
warnings.warn(
Steps to Reproduce
Run the test suite:
pytest
The warnings appear in the output during test execution.
Analysis
pytest-asyncio Warning
- The current test suite uses a custom
event_loop
fixture intests/conftest.py
- pytest-asyncio now recommends using
event_loop_policy
fixtures or scope arguments instead - Critical: Attempts to fix this by modifying the event loop configuration break the Redis async connection handling throughout the test suite
Pydantic Warning
- Test cases use a field named
dict
which shadows the built-indict
attribute - Located in
tests/test_json_model.py
andtests_sync/test_json_model.py
in thetest_model_with_dict
functions
Impact
- Low Priority: Warnings are cosmetic and don't affect test functionality
- No Immediate Action Required: The test suite works correctly despite the warnings
- Future Consideration: May need addressing if warnings become errors in future library versions
Investigation Notes
Extensive investigation revealed that:
- Any attempt to modify the pytest-asyncio configuration to eliminate the warning causes widespread test failures with "Event loop is closed" and "Future attached to a different loop" errors
- The current async architecture is tightly coupled to the existing event loop fixture
- The warnings appear to be harmless but indicate potential future compatibility issues
Recommendation
- Short term: Leave warnings as-is since fixing them breaks functionality
- Long term: Consider updating the async test architecture when upgrading pytest-asyncio versions
- Monitor: Keep an eye on pytest-asyncio releases for better migration paths
Environment
- Python 3.12.9
- pytest-asyncio 0.24.0
- pydantic 2.x