MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / process_statement

Method process_statement

lib/sqlalchemy/testing/assertsql.py:162–211  ·  view source on GitHub ↗
(self, execute_observed)

Source from the content-addressed store, hash-verified

160 return _received_statement, _received_parameters
161
162 def process_statement(self, execute_observed):
163 context = execute_observed.context
164
165 _received_statement, _received_parameters = self._received_statement(
166 execute_observed
167 )
168 params = self._all_params(context)
169
170 equivalent = self._compare_sql(execute_observed, _received_statement)
171
172 if equivalent:
173 if params is not None:
174 all_params = list(params)
175 all_received = list(_received_parameters)
176 while all_params and all_received:
177 param = dict(all_params.pop(0))
178
179 for idx, received in enumerate(list(all_received)):
180 # do a positive compare only
181 for param_key in param:
182 # a key in param did not match current
183 # 'received'
184 if (
185 param_key not in received
186 or received[param_key] != param[param_key]
187 ):
188 break
189 else:
190 # all keys in param matched 'received';
191 # onto next param
192 del all_received[idx]
193 break
194 else:
195 # param did not match any entry
196 # in all_received
197 equivalent = False
198 break
199 if all_params or all_received:
200 equivalent = False
201
202 if equivalent:
203 self.is_consumed = True
204 self.errormessage = None
205 else:
206 self.errormessage = self._failure_message(
207 execute_observed, params
208 ) % {
209 "received_statement": _received_statement,
210 "received_parameters": _received_parameters,
211 }
212
213 def _all_params(self, context):
214 if self.params:

Callers

nothing calls this directly

Calls 5

_received_statementMethod · 0.95
_all_paramsMethod · 0.95
_compare_sqlMethod · 0.95
_failure_messageMethod · 0.95
popMethod · 0.45

Tested by

no test coverage detected