MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_normal_load

Method test_normal_load

test/orm/test_attributes.py:1688–1713  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1686 eq_(lazy_posts.call_count, 2)
1687
1688 def test_normal_load(self):
1689 Post, Blog, lazy_posts = self._fixture()
1690
1691 lazy_posts.return_value = (p1, p2, p3) = [
1692 Post("post 1"),
1693 Post("post 2"),
1694 Post("post 3"),
1695 ]
1696
1697 b = Blog("blog 1")
1698
1699 # assign without using backref system
1700 p2.__dict__["blog"] = b
1701
1702 eq_(b.posts, [Post("post 1"), Post("post 2"), Post("post 3")])
1703
1704 eq_(lazy_posts.call_count, 1)
1705 p2.blog = None
1706 p4 = Post("post 4")
1707 p4.blog = b
1708 eq_(b.posts, [Post("post 1"), Post("post 3"), Post("post 4")])
1709
1710 b_state = attributes.instance_state(b)
1711
1712 eq_(lazy_posts.call_count, 1)
1713 eq_(lazy_posts.mock_calls, [call(b_state, attributes.PASSIVE_OFF)])
1714
1715 def test_commit_removes_pending(self):
1716 Post, Blog, lazy_posts = self._fixture()

Callers

nothing calls this directly

Calls 5

_fixtureMethod · 0.95
eq_Function · 0.90
callFunction · 0.85
PostClass · 0.70
BlogClass · 0.70

Tested by

no test coverage detected