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

Function test__clear

tests/fields/test_m2m.py:102–111  ·  view source on GitHub ↗

Test clearing all related objects from M2M relation.

(db)

Source from the content-addressed store, hash-verified

100
101@pytest.mark.asyncio
102async def test__clear(db):
103 """Test clearing all related objects from M2M relation."""
104 one = await testmodels.M2MOne.create(name="One")
105 two1 = await testmodels.M2MTwo.create(name="Two")
106 two2 = await testmodels.M2MTwo.create(name="Two")
107 await one.two.add(two1, two2)
108 await one.two.clear()
109 assert await one.two == []
110 assert await two1.one == []
111 assert await two2.one == []
112
113
114@pytest.mark.asyncio

Callers

nothing calls this directly

Calls 3

addMethod · 0.80
createMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…