|
6 | 6 | import decimal
|
7 | 7 | from collections.abc import AsyncGenerator, Collection, Generator
|
8 | 8 | from typing import TYPE_CHECKING, Any, Union, cast
|
9 |
| -from unittest.mock import AsyncMock, MagicMock |
| 9 | +from unittest.mock import AsyncMock, MagicMock, PropertyMock |
10 | 10 | from uuid import uuid4
|
11 | 11 |
|
12 | 12 | import pytest
|
13 | 13 | from msgspec import Struct
|
14 | 14 | from pydantic import BaseModel
|
15 | 15 | from pytest_lazy_fixtures import lf
|
16 | 16 | from sqlalchemy import Integer, String
|
17 |
| -from sqlalchemy.exc import SQLAlchemyError |
| 17 | +from sqlalchemy.exc import InvalidRequestError, SQLAlchemyError |
18 | 18 | from sqlalchemy.ext.asyncio import AsyncSession
|
19 | 19 | from sqlalchemy.orm import InstrumentedAttribute, Mapped, Session, mapped_column
|
20 | 20 | from sqlalchemy.types import TypeEngine
|
@@ -1509,8 +1509,8 @@ async def test_update_skips_raise_lazy_relationships(
|
1509 | 1509 | mock_mapper.mapper.columns = []
|
1510 | 1510 | mock_mapper.mapper.relationships = [mock_relationship]
|
1511 | 1511 |
|
1512 |
| - # Mock the data object to have the raise relationship attribute |
1513 |
| - mock_instance.items = MagicMock() |
| 1512 | + # Mock the data object to raise an error when accessing the relationship |
| 1513 | + type(mock_instance).items = PropertyMock(side_effect=InvalidRequestError) |
1514 | 1514 |
|
1515 | 1515 | mocker.patch.object(mock_repo, "get_id_attribute_value", return_value=id_)
|
1516 | 1516 | mocker.patch.object(mock_repo, "get", return_value=existing_instance)
|
|
0 commit comments