MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_replace_persistent

Method test_replace_persistent

test/orm/test_dynamic.py:2105–2132  ·  view source on GitHub ↗
(self, autoflush, persistent_fixture)

Source from the content-addressed store, hash-verified

2103
2104 @testing.combinations(True, False, argnames="autoflush")
2105 def test_replace_persistent(self, autoflush, persistent_fixture):
2106 User = self.classes.User
2107 Address = self.classes.Address
2108
2109 u1, a1, s = persistent_fixture(autoflush=autoflush)
2110 a2, a3, a4, a5 = (
2111 Address(email_address="a2"),
2112 Address(email_address="a3"),
2113 Address(email_address="a4"),
2114 Address(email_address="a5"),
2115 )
2116
2117 if User.addresses.property.lazy == "write_only":
2118 with self._expect_no_iteration():
2119 u1.addresses = [a1, a2]
2120 return
2121
2122 u1.addresses = [a1, a2]
2123 u1.addresses = [a2, a3, a4, a5]
2124
2125 if not autoflush:
2126 self._assert_history(u1, ([a2, a3, a4, a5], [], []))
2127 else:
2128 self._assert_history(
2129 u1,
2130 ([a3, a4, a5], [a2], [a1]),
2131 compare_passive=([a3, a4, a5], [], [a1]),
2132 )
2133
2134 @testing.combinations(True, False, argnames="autoflush")
2135 def test_persistent_but_readded(self, autoflush, persistent_fixture):

Callers

nothing calls this directly

Calls 3

_assert_historyMethod · 0.95
_expect_no_iterationMethod · 0.80
AddressClass · 0.70

Tested by

no test coverage detected