@@ -7365,17 +7365,16 @@ def test_datetimeoffset_read_write(cursor, db_connection):
73657365 datetime (2023 , 10 , 27 , 15 , 45 , 10 , 123456 , tzinfo = timezone (timedelta (hours = - 8 ))),
73667366 datetime (2023 , 10 , 28 , 20 , 0 , 5 , 987654 , tzinfo = timezone .utc )
73677367 ]
7368-
7369- cursor .execute ("IF OBJECT_ID('tempdb..#dto_test', 'U') IS NOT NULL DROP TABLE #dto_test;" )
7370- cursor .execute ("CREATE TABLE #dto_test (id INT PRIMARY KEY, dto_column DATETIMEOFFSET);" )
7368+
7369+ cursor .execute ("CREATE TABLE #pytest_datetimeoffset_read_write (id INT PRIMARY KEY, dto_column DATETIMEOFFSET);" )
73717370 db_connection .commit ()
7372-
7373- insert_stmt = "INSERT INTO #dto_test (id, dto_column) VALUES (?, ?);"
7371+
7372+ insert_stmt = "INSERT INTO #pytest_datetimeoffset_read_write (id, dto_column) VALUES (?, ?);"
73747373 for i , dt in enumerate (test_cases ):
73757374 cursor .execute (insert_stmt , i , dt )
73767375 db_connection .commit ()
7377-
7378- cursor .execute ("SELECT id, dto_column FROM #dto_test ORDER BY id;" )
7376+
7377+ cursor .execute ("SELECT id, dto_column FROM #pytest_datetimeoffset_read_write ORDER BY id;" )
73797378 for i , dt in enumerate (test_cases ):
73807379 row = cursor .fetchone ()
73817380 assert row is not None
@@ -7388,7 +7387,7 @@ def test_datetimeoffset_read_write(cursor, db_connection):
73887387 fetched_utc = fetched_utc .replace (microsecond = int (fetched_utc .microsecond / 1000 ) * 1000 )
73897388 assert fetched_utc == expected_utc
73907389 finally :
7391- cursor .execute ("DROP TABLE IF EXISTS #dto_test ;" )
7390+ cursor .execute ("DROP TABLE IF EXISTS #pytest_datetimeoffset_read_write ;" )
73927391 db_connection .commit ()
73937392
73947393def test_datetimeoffset_max_min_offsets (cursor , db_connection ):
@@ -7397,21 +7396,20 @@ def test_datetimeoffset_max_min_offsets(cursor, db_connection):
73977396 Uses fetchone() for retrieval.
73987397 """
73997398 try :
7400- cursor .execute ("IF OBJECT_ID('tempdb..#dto_offsets', 'U') IS NOT NULL DROP TABLE #dto_offsets;" )
7401- cursor .execute ("CREATE TABLE #dto_offsets (id INT PRIMARY KEY, dto_column DATETIMEOFFSET);" )
7399+ cursor .execute ("CREATE TABLE #pytest_datetimeoffset_read_write (id INT PRIMARY KEY, dto_column DATETIMEOFFSET);" )
74027400 db_connection .commit ()
74037401
74047402 test_cases = [
74057403 (1 , datetime (2025 , 1 , 1 , 12 , 0 , 0 , tzinfo = timezone (timedelta (hours = 14 )))), # max offset
74067404 (2 , datetime (2025 , 1 , 1 , 12 , 0 , 0 , tzinfo = timezone (timedelta (hours = - 14 )))), # min offset
74077405 ]
74087406
7409- insert_stmt = "INSERT INTO #dto_offsets (id, dto_column) VALUES (?, ?);"
7407+ insert_stmt = "INSERT INTO #pytest_datetimeoffset_read_write (id, dto_column) VALUES (?, ?);"
74107408 for row_id , dt in test_cases :
74117409 cursor .execute (insert_stmt , row_id , dt )
74127410 db_connection .commit ()
74137411
7414- cursor .execute ("SELECT id, dto_column FROM #dto_offsets ORDER BY id;" )
7412+ cursor .execute ("SELECT id, dto_column FROM #pytest_datetimeoffset_read_write ORDER BY id;" )
74157413
74167414 for expected_id , expected_dt in test_cases :
74177415 row = cursor .fetchone ()
@@ -7429,24 +7427,24 @@ def test_datetimeoffset_max_min_offsets(cursor, db_connection):
74297427 )
74307428
74317429 finally :
7432- cursor .execute ("IF OBJECT_ID('tempdb..#dto_offsets', 'U') IS NOT NULL DROP TABLE #dto_offsets ;" )
7430+ cursor .execute ("DROP TABLE IF EXISTS #pytest_datetimeoffset_read_write ;" )
74337431 db_connection .commit ()
74347432
74357433def test_datetimeoffset_invalid_offsets (cursor , db_connection ):
74367434 """Verify driver rejects offsets beyond ±14 hours."""
74377435 try :
7438- cursor .execute ("CREATE TABLE #dto_invalid (id INT PRIMARY KEY, dto_column DATETIMEOFFSET);" )
7436+ cursor .execute ("CREATE TABLE #pytest_datetimeoffset_invalid_offsets (id INT PRIMARY KEY, dto_column DATETIMEOFFSET);" )
74397437 db_connection .commit ()
74407438
74417439 with pytest .raises (Exception ):
7442- cursor .execute ("INSERT INTO #dto_invalid (id, dto_column) VALUES (?, ?);" ,
7440+ cursor .execute ("INSERT INTO #pytest_datetimeoffset_invalid_offsets (id, dto_column) VALUES (?, ?);" ,
74437441 1 , datetime (2025 , 1 , 1 , 12 , 0 , tzinfo = timezone (timedelta (hours = 15 ))))
74447442
74457443 with pytest .raises (Exception ):
7446- cursor .execute ("INSERT INTO #dto_invalid (id, dto_column) VALUES (?, ?);" ,
7444+ cursor .execute ("INSERT INTO #pytest_datetimeoffset_invalid_offsets (id, dto_column) VALUES (?, ?);" ,
74477445 2 , datetime (2025 , 1 , 1 , 12 , 0 , tzinfo = timezone (timedelta (hours = - 15 ))))
74487446 finally :
7449- cursor .execute ("DROP TABLE IF EXISTS #dto_invalid ;" )
7447+ cursor .execute ("DROP TABLE IF EXISTS #pytest_datetimeoffset_invalid_offsets ;" )
74507448 db_connection .commit ()
74517449
74527450def test_datetimeoffset_dst_transitions (cursor , db_connection ):
@@ -7455,8 +7453,7 @@ def test_datetimeoffset_dst_transitions(cursor, db_connection):
74557453 Ensures that driver handles DST correctly and does not crash.
74567454 """
74577455 try :
7458- cursor .execute ("IF OBJECT_ID('tempdb..#dto_dst', 'U') IS NOT NULL DROP TABLE #dto_dst;" )
7459- cursor .execute ("CREATE TABLE #dto_dst (id INT PRIMARY KEY, dto_column DATETIMEOFFSET);" )
7456+ cursor .execute ("CREATE TABLE #pytest_datetimeoffset_dst_transitions (id INT PRIMARY KEY, dto_column DATETIMEOFFSET);" )
74607457 db_connection .commit ()
74617458
74627459 # Example DST transition dates (replace with actual region offset if needed)
@@ -7467,12 +7464,12 @@ def test_datetimeoffset_dst_transitions(cursor, db_connection):
74677464 (4 , datetime (2025 , 11 , 2 , 1 , 0 , 0 , tzinfo = timezone (timedelta (hours = - 5 )))), # Just after fall back
74687465 ]
74697466
7470- insert_stmt = "INSERT INTO #dto_dst (id, dto_column) VALUES (?, ?);"
7467+ insert_stmt = "INSERT INTO #pytest_datetimeoffset_dst_transitions (id, dto_column) VALUES (?, ?);"
74717468 for row_id , dt in dst_test_cases :
74727469 cursor .execute (insert_stmt , row_id , dt )
74737470 db_connection .commit ()
74747471
7475- cursor .execute ("SELECT id, dto_column FROM #dto_dst ORDER BY id;" )
7472+ cursor .execute ("SELECT id, dto_column FROM #pytest_datetimeoffset_dst_transitions ORDER BY id;" )
74767473
74777474 for expected_id , expected_dt in dst_test_cases :
74787475 row = cursor .fetchone ()
@@ -7490,36 +7487,36 @@ def test_datetimeoffset_dst_transitions(cursor, db_connection):
74907487 )
74917488
74927489 finally :
7493- cursor .execute ("IF OBJECT_ID('tempdb..#dto_dst', 'U') IS NOT NULL DROP TABLE #dto_dst ;" )
7490+ cursor .execute ("DROP TABLE IF EXISTS #pytest_datetimeoffset_dst_transitions ;" )
74947491 db_connection .commit ()
74957492
74967493def test_datetimeoffset_leap_second (cursor , db_connection ):
74977494 """Ensure driver handles leap-second-like microsecond edge cases without crashing."""
74987495 try :
7499- cursor .execute ("CREATE TABLE #dto_leap (id INT PRIMARY KEY, dto_column DATETIMEOFFSET);" )
7496+ cursor .execute ("CREATE TABLE #pytest_datetimeoffset_leap_second (id INT PRIMARY KEY, dto_column DATETIMEOFFSET);" )
75007497 db_connection .commit ()
75017498
75027499 leap_second_sim = datetime (2023 , 12 , 31 , 23 , 59 , 59 , 999999 , tzinfo = timezone .utc )
7503- cursor .execute ("INSERT INTO #dto_leap (id, dto_column) VALUES (?, ?);" , 1 , leap_second_sim )
7500+ cursor .execute ("INSERT INTO #pytest_datetimeoffset_leap_second (id, dto_column) VALUES (?, ?);" , 1 , leap_second_sim )
75047501 db_connection .commit ()
7505-
7506- row = cursor .execute ("SELECT dto_column FROM #dto_leap ;" ).fetchone ()
7502+
7503+ row = cursor .execute ("SELECT dto_column FROM #pytest_datetimeoffset_leap_second ;" ).fetchone ()
75077504 assert row [0 ].tzinfo is not None
75087505 finally :
7509- cursor .execute ("DROP TABLE IF EXISTS #dto_leap ;" )
7506+ cursor .execute ("DROP TABLE IF EXISTS #pytest_datetimeoffset_leap_second ;" )
75107507 db_connection .commit ()
75117508
75127509def test_datetimeoffset_malformed_input (cursor , db_connection ):
75137510 """Verify driver raises error for invalid datetimeoffset strings."""
75147511 try :
7515- cursor .execute ("CREATE TABLE #dto_malformed (id INT PRIMARY KEY, dto_column DATETIMEOFFSET);" )
7512+ cursor .execute ("CREATE TABLE #pytest_datetimeoffset_malformed_input (id INT PRIMARY KEY, dto_column DATETIMEOFFSET);" )
75167513 db_connection .commit ()
75177514
75187515 with pytest .raises (Exception ):
7519- cursor .execute ("INSERT INTO #dto_malformed (id, dto_column) VALUES (?, ?);" ,
7516+ cursor .execute ("INSERT INTO #pytest_datetimeoffset_malformed_input (id, dto_column) VALUES (?, ?);" ,
75207517 1 , "2023-13-45 25:61:00 +99:99" ) # invalid string
75217518 finally :
7522- cursor .execute ("DROP TABLE IF EXISTS #dto_malformed ;" )
7519+ cursor .execute ("DROP TABLE IF EXISTS #pytest_datetimeoffset_malformed_input ;" )
75237520 db_connection .commit ()
75247521
75257522def test_lowercase_attribute (cursor , db_connection ):
0 commit comments