MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_extract

Method test_extract

test/dialect/postgresql/test_dialect.py:1340–1359  ·  view source on GitHub ↗
(self, connection)

Source from the content-addressed store, hash-verified

1338 )
1339
1340 def test_extract(self, connection):
1341 fivedaysago = connection.execute(
1342 select(func.now().op("at time zone")("UTC"))
1343 ).scalar() - datetime.timedelta(days=5)
1344
1345 for field, exp in (
1346 ("year", fivedaysago.year),
1347 ("month", fivedaysago.month),
1348 ("day", fivedaysago.day),
1349 ):
1350 r = connection.execute(
1351 select(
1352 extract(
1353 field,
1354 func.now().op("at time zone")("UTC")
1355 + datetime.timedelta(days=-5),
1356 )
1357 )
1358 ).scalar()
1359 eq_(r, exp)
1360
1361 @testing.provide_metadata
1362 def test_checksfor_sequence(self, connection):

Callers

nothing calls this directly

Calls 7

selectFunction · 0.90
extractFunction · 0.90
eq_Function · 0.90
nowMethod · 0.80
scalarMethod · 0.45
executeMethod · 0.45
opMethod · 0.45

Tested by

no test coverage detected