Path: blob/main/singlestoredb/tests/test_exceptions.py
469 views
#!/usr/bin/env python1# type: ignore2"""Test SingleStoreDB exceptions."""3import unittest45import singlestoredb as s2678class TestExceptions(unittest.TestCase):910def test_str(self):11exc = s2.Error()12assert str(exc) == 'Unknown error', str(exc)1314exc = s2.Error(errno=1)15assert str(exc) == '1', str(exc)1617exc = s2.Error(msg='hi there')18assert str(exc) == 'hi there', str(exc)1920exc = s2.Error(errno=1, msg='hi there')21assert str(exc) == '1: hi there', str(exc)2223exc = s2.Error(errno=1, msg='hi there', sqlstate=9)24assert str(exc) == '1 (9): hi there'2526exc = s2.Error(msg='hi there', sqlstate=9)27assert str(exc) == '(9): hi there'2829exc = s2.Error(sqlstate=9)30assert str(exc) == '(9)'3132def test_repr(self):33exc = s2.Error(errno=1, msg='hi there')34assert str(exc) == '1: hi there', str(exc)35assert str(exc) == repr(exc)3637def test_msg(self):38exc = s2.Error(errno=1, msg='hi there')39assert exc.msg == exc.errmsg404142if __name__ == '__main__':43import nose244nose2.main()454647