forked from snowflakedb/snowflake-connector-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_errors.py
More file actions
34 lines (27 loc) · 911 Bytes
/
test_errors.py
File metadata and controls
34 lines (27 loc) · 911 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright (c) 2012-2018 Snowflake Computing Inc. All right reserved.
#
import snowflake.connector
from snowflake.connector import errors
def test_error_classes(conn_cnx):
u"""
Error classes in Connector module, object
"""
# class
assert snowflake.connector.ProgrammingError == errors.ProgrammingError
assert snowflake.connector.OperationalError == errors.OperationalError
# object
with conn_cnx() as ctx:
assert ctx.ProgrammingError == errors.ProgrammingError
def test_error_code(conn_cnx):
u"""
Error code is included in the exception
"""
with conn_cnx() as ctx:
try:
ctx.cursor().execute(u"SELECT * FROOOM TEST")
raise Exception('Failed to detect Syntax error')
except errors.ProgrammingError as e:
assert e.errno == 1003, u"Syntax error code"