MCPcopy Create free account
hub / github.com/sqlalchemy/sqlalchemy / test_extract

Method test_extract

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

Source from the content-addressed store, hash-verified

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

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