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
|
from ctypes.util import find_library
|
||||||
|
|
||||||
import psycopg2
|
import psycopg2
|
||||||
|
import psycopg2.errors
|
||||||
import psycopg2.extensions
|
import psycopg2.extensions
|
||||||
from psycopg2.compat import text_type
|
from psycopg2.compat import text_type
|
||||||
|
|
||||||
|
@ -372,12 +373,8 @@ def skip_if_no_superuser(f):
|
||||||
def skip_if_no_superuser_(self):
|
def skip_if_no_superuser_(self):
|
||||||
try:
|
try:
|
||||||
return f(self)
|
return f(self)
|
||||||
except psycopg2.ProgrammingError as e:
|
except psycopg2.errors.InsufficientPrivilege:
|
||||||
import psycopg2.errorcodes
|
self.skipTest("skipped because not superuser")
|
||||||
if e.pgcode == psycopg2.errorcodes.INSUFFICIENT_PRIVILEGE:
|
|
||||||
self.skipTest("skipped because not superuser")
|
|
||||||
else:
|
|
||||||
raise
|
|
||||||
|
|
||||||
return skip_if_no_superuser_
|
return skip_if_no_superuser_
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user