MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / time_passes

Function time_passes

examples/versioned_rows/versioned_update_old_row.py:167–184  ·  view source on GitHub ↗

keep track of timestamps in terms of the database and allow time to pass between steps.

(s)

Source from the content-addressed store, hash-verified

165
166
167def time_passes(s):
168 """keep track of timestamps in terms of the database and allow time to
169 pass between steps."""
170
171 # close the transaction, if any, since PG time doesn't increment in the
172 # transaction
173 s.commit()
174
175 # get "now" in terms of the DB so we can keep the ranges low and
176 # still have our assertions pass
177 if times:
178 time.sleep(1)
179
180 times.append(datetime.datetime.now())
181
182 if len(times) > 1:
183 assert times[-1] > times[-2]
184 return times[-1]
185
186
187e = create_engine("sqlite://", echo="debug")

Callers 1

Calls 3

nowMethod · 0.80
commitMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected