diff options
author | Daniele Varrazzo <daniele.varrazzo@gmail.com> | 2013-03-16 11:56:38 +0000 |
---|---|---|
committer | Daniele Varrazzo <daniele.varrazzo@gmail.com> | 2013-03-16 11:56:38 +0000 |
commit | 66d6c68dcc3a3f20742b29edbc005c7417c4b374 (patch) | |
tree | dc4c1be140a8c971f8b32939d7a19002aba83251 /tests/testutils.py | |
parent | 7abe1775d0bc037494576691172ece437dea3761 (diff) | |
download | psycopg2-66d6c68dcc3a3f20742b29edbc005c7417c4b374.tar.gz |
Properly cleanup memory of broken connections
Fixed ticket #148.
Diffstat (limited to 'tests/testutils.py')
-rw-r--r-- | tests/testutils.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/testutils.py b/tests/testutils.py index 26551d4..068a913 100644 --- a/tests/testutils.py +++ b/tests/testutils.py @@ -207,6 +207,21 @@ def skip_from_python(*ver): return skip_from_python__ return skip_from_python_ +def skip_if_no_superuser(f): + """Skip a test if the database user running the test is not a superuser""" + def skip_if_no_superuser_(self): + from psycopg2 import ProgrammingError + try: + return f(self) + except ProgrammingError, e: + import psycopg2.errorcodes + if e.pgcode == psycopg2.errorcodes.INSUFFICIENT_PRIVILEGE: + self.skipTest("skipped because not superuser") + else: + raise + + return skip_if_no_superuser_ + def script_to_py3(script): """Convert a script to Python3 syntax if required.""" |