MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_methods_etc

Method test_methods_etc

test/orm/test_scoping.py:138–174  ·  test/orm/test_scoping.py::ScopedSessionTest.test_methods_etc
(self)

Source from the content-addressed store, hash-verified

136 assert s2.autoflush == False
137
138 def test_methods_etc(self):
139 mock_session = Mock()
140 mock_session.bind = class="st">"the bind"
141
142 sess = scoped_session(lambda: mock_session)
143
144 sess.add(class="st">"add")
145 sess.delete(class="st">"delete")
146
147 sess.get(class="st">"Cls", 5)
148
149 eq_(sess.bind, class="st">"the bind")
150
151 eq_(
152 mock_session.mock_calls,
153 [
154 mock.call.add(class="st">"add", _warn=True),
155 mock.call.delete(class="st">"delete"),
156 mock.call.get(
157 class="st">"Cls",
158 5,
159 options=None,
160 populate_existing=None,
161 with_for_update=None,
162 identity_token=None,
163 execution_options=util.EMPTY_DICT,
164 bind_arguments=None,
165 ),
166 ],
167 )
168
169 with mock.patch(
170 class="st">"sqlalchemy.orm.session.object_session"
171 ) as mock_object_session:
172 sess.object_session(class="st">"foo")
173
174 eq_(mock_object_session.mock_calls, [mock.call(class="st">"foo")])
175
176 @testing.combinations(
177 class="st">"style1",

Callers

nothing calls this directly

Calls 6

scoped_sessionClass · 0.90
eq_Function · 0.90
addMethod · 0.45
deleteMethod · 0.45
getMethod · 0.45
object_sessionMethod · 0.45

Tested by

no test coverage detected