mirror of
https://github.com/psycopg/psycopg2.git
synced 2024-11-25 18:33:44 +03:00
Use errors module to catch a specific postgres error
This commit is contained in:
parent
b0119fef81
commit
e8135ee2cf
|
@ -34,6 +34,7 @@ from functools import wraps
|
|||
from ctypes.util import find_library
|
||||
|
||||
import psycopg2
|
||||
import psycopg2.errors
|
||||
import psycopg2.extensions
|
||||
from psycopg2.compat import text_type
|
||||
|
||||
|
@ -372,12 +373,8 @@ def skip_if_no_superuser(f):
|
|||
def skip_if_no_superuser_(self):
|
||||
try:
|
||||
return f(self)
|
||||
except psycopg2.ProgrammingError as e:
|
||||
import psycopg2.errorcodes
|
||||
if e.pgcode == psycopg2.errorcodes.INSUFFICIENT_PRIVILEGE:
|
||||
except psycopg2.errors.InsufficientPrivilege:
|
||||
self.skipTest("skipped because not superuser")
|
||||
else:
|
||||
raise
|
||||
|
||||
return skip_if_no_superuser_
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user