MCPcopy Create free account
hub / github.com/tortoise/tortoise-orm / test__add_uninstantiated

Function test__add_uninstantiated

tests/fields/test_m2m.py:124–129  ·  view source on GitHub ↗

Test that adding unsaved model raises OperationalError.

(db)

Source from the content-addressed store, hash-verified

122
123@pytest.mark.asyncio
124async def test__add_uninstantiated(db):
125 """Test that adding unsaved model raises OperationalError."""
126 one = testmodels.M2MOne(name="One")
127 two = await testmodels.M2MTwo.create(name="Two")
128 with pytest.raises(OperationalError, match=r"You should first call .save\(\) on <M2MOne>"):
129 await two.one.add(one)
130
131
132@pytest.mark.asyncio

Callers

nothing calls this directly

Calls 2

addMethod · 0.80
createMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…