@@ -80,7 +80,7 @@ def test_bool_to_connection_string_arg(key: str, value: bool, expected: str) ->
80
80
assert bool_to_connection_string_arg (key , value ) == expected
81
81
82
82
@pytest .mark .parametrize (
83
- "value, expected " , [
83
+ "value, expected_datetime, expected_str " , [
84
84
(
85
85
bytes ([
86
86
0xE5 , 0x07 , # year: 2022
@@ -89,17 +89,19 @@ def test_bool_to_connection_string_arg(key: str, value: bool, expected: str) ->
89
89
0x16 , 0x00 , # hour: 22
90
90
0x16 , 0x00 , # minute: 22
91
91
0x12 , 0x00 , # second: 18
92
- 0x40 , 0xE2 , 0x01 , 0x00 , # microsecond: 123456
92
+ 0x15 , 0xCD , 0x5B , 0x07 , # microsecond: 123456789
93
93
0x02 , 0x00 , 0x1E , 0x00 # tzinfo: +02:30
94
94
]),
95
+ dt .datetime (2022 , 12 , 17 , 22 , 22 , 18 , 123456 , dt .timezone (dt .timedelta (hours = 2 , minutes = 30 ))),
95
96
"2021-12-17 22:22:18.123456+02:30"
96
97
)
97
98
]
98
99
)
99
- def test_byte_array_to_datetime (value : bytes , expected : dt .datetime ) -> None :
100
+ def test_byte_array_to_datetime (value : bytes , expected_datetime : dt .datetime , expected_str : str ) -> None :
100
101
"""
101
102
Assert SQL_SS_TIMESTAMPOFFSET_STRUCT bytes convert to string in an expected isoformat
102
103
https://docs.python.org/3/library/datetime.html#datetime.datetime.__str__
103
104
https://learn.microsoft.com/sql/relational-databases/native-client-odbc-date-time/data-type-support-for-odbc-date-and-time-improvements#sql_ss_timestampoffset_struct
104
105
"""
105
- assert str (byte_array_to_datetime (value )) == expected
106
+ assert byte_array_to_datetime (value ) == expected_datetime
107
+ assert str (byte_array_to_datetime (value )) == expected_str
0 commit comments