File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11/build
2+ /comdb2.egg-info /
23/dist
34/python_comdb2.egg-info
45* .pyc
Original file line number Diff line number Diff line change 2828 DataError ,
2929 Datetime ,
3030 DatetimeUs ,
31- Error ,
3231 ForeignKeyConstraintError ,
3332 IntegrityError ,
3433 InterfaceError ,
@@ -793,6 +792,21 @@ def raise_not_supported_error():
793792 conn .commit ()
794793
795794
795+ @patch ("comdb2.cdb2.Handle" )
796+ def test_error_wraps_underlying (handle ):
797+ handle .return_value .execute .side_effect = partial (throw_on , "begin" )
798+
799+ conn = connect ("mattdb" , "dev" )
800+ cursor = conn .cursor ()
801+
802+ with pytest .raises (OperationalError ) as exc_info :
803+ cursor .execute ("insert into simple(key, val) values(1, 2)" )
804+
805+ assert isinstance (exc_info .value .__cause__ , cdb2 .Error )
806+ underlying = exc_info .value .__cause__
807+ assert underlying .error_code == 42
808+
809+
796810def test_autocommit_handles ():
797811 conn = connect ("mattdb" , "dev" , autocommit = True )
798812 cursor = conn .cursor ()
@@ -936,8 +950,7 @@ def test_unsupported_column_decode_exception():
936950 cursor .fetchall ()
937951
938952 errmsg = (
939- "Failed to decode CDB2_INTERVALDS column 0 ('delta'):"
940- " Unsupported column type"
953+ "Failed to decode CDB2_INTERVALDS column 0 ('delta'): Unsupported column type"
941954 )
942955 assert errmsg in str (exc_info .value )
943956
You can’t perform that action at this time.
0 commit comments