77conn .autocommit = True
88
99
10- def assert_select_all (results : list [psycopg .rows .Row ]):
10+ def assert_select_all (results : list [psycopg .rows .Row ], format : str ):
1111 expected = [
1212 (
1313 1 ,
@@ -17,8 +17,16 @@ def assert_select_all(results: list[psycopg.rows.Row]):
1717 date (2012 , 1 , 1 ),
1818 datetime (2012 , 1 , 1 ),
1919 [1 , 2 ],
20- (10 , "x" , date (2012 , 1 , 1 ), datetime (2012 , 1 , 1 )),
21- [(10 , "x" , date (2012 , 1 , 1 ), datetime (2012 , 1 , 1 ))],
20+ (
21+ (10 , "x" , date (2012 , 1 , 1 ), datetime (2012 , 1 , 1 ))
22+ if format == "binary"
23+ else ("10" , "x" , "2012-01-01" , "2012-01-01 00:00:00.000000" )
24+ ),
25+ (
26+ [(10 , "x" , date (2012 , 1 , 1 ), datetime (2012 , 1 , 1 ))]
27+ if format == "binary"
28+ else [("10" , "x" , "2012-01-01" , "2012-01-01 00:00:00.000000" )]
29+ ),
2230 ),
2331 (
2432 2 ,
@@ -28,8 +36,18 @@ def assert_select_all(results: list[psycopg.rows.Row]):
2836 date (2012 , 1 , 2 ),
2937 datetime (2012 , 1 , 2 ),
3038 [3 , 4 ],
31- (20 , "y" , date (2012 , 1 , 2 ), datetime (2012 , 1 , 2 , 0 , 0 )),
32- [(20 , "y" , date (2012 , 1 , 2 ), datetime (2012 , 1 , 2 , 0 , 0 ))],
39+ (
40+ (20 , "y" , date (2012 , 1 , 2 ), datetime (2012 , 1 , 2 , 0 , 0 ))
41+ if format == "binary"
42+ else ("20" , "y" , "2012-01-02" , "2012-01-02 00:00:00.000000" )
43+ ),
44+ [
45+ (
46+ (20 , "y" , date (2012 , 1 , 2 ), datetime (2012 , 1 , 2 , 0 , 0 ))
47+ if format == "binary"
48+ else ("20" , "y" , "2012-01-02" , "2012-01-02 00:00:00.000000" )
49+ ),
50+ ],
3351 ),
3452 (
3553 3 ,
@@ -39,8 +57,18 @@ def assert_select_all(results: list[psycopg.rows.Row]):
3957 date (2012 , 1 , 3 ),
4058 datetime (2012 , 1 , 3 ),
4159 [5 , 6 ],
42- (30 , "z" , date (2012 , 1 , 3 ), datetime (2012 , 1 , 3 , 0 , 0 )),
43- [(30 , "z" , date (2012 , 1 , 3 ), datetime (2012 , 1 , 3 , 0 , 0 ))],
60+ (
61+ (30 , "z" , date (2012 , 1 , 3 ), datetime (2012 , 1 , 3 , 0 , 0 ))
62+ if format == "binary"
63+ else ("30" , "z" , "2012-01-03" , "2012-01-03 00:00:00.000000" )
64+ ),
65+ [
66+ (
67+ (30 , "z" , date (2012 , 1 , 3 ), datetime (2012 , 1 , 3 , 0 , 0 ))
68+ if format == "binary"
69+ else ("30" , "z" , "2012-01-03" , "2012-01-03 00:00:00.000000" )
70+ ),
71+ ],
4472 ),
4573 ]
4674
@@ -69,9 +97,9 @@ def assert_select_all(results: list[psycopg.rows.Row]):
6997with conn .cursor (binary = True ) as cur :
7098 cur .execute ("SELECT * FROM all_types" )
7199 results = cur .fetchall ()
72- assert_select_all (results )
100+ assert_select_all (results , "binary" )
73101
74102with conn .cursor (binary = False ) as cur :
75103 cur .execute ("SELECT * FROM all_types" )
76104 results = cur .fetchall ()
77- assert_select_all (results )
105+ assert_select_all (results , "text" )
0 commit comments