diff options
author | Daniele Varrazzo <daniele.varrazzo@gmail.com> | 2011-02-19 00:05:43 +0000 |
---|---|---|
committer | Daniele Varrazzo <daniele.varrazzo@gmail.com> | 2011-02-19 00:05:43 +0000 |
commit | c620f18be14b994337a3bb939974e1fb769823fd (patch) | |
tree | fd450abdf6103a04ead99f9a7512ab45af8eb14d /tests/testutils.py | |
parent | e2cbc3411dbfa901422241f75cd5906aaa8181f4 (diff) | |
download | psycopg2-c620f18be14b994337a3bb939974e1fb769823fd.tar.gz |
Provide cursor.description as named tuple if possible
If namedtuple() is not available, use regular tuples.
Diffstat (limited to 'tests/testutils.py')
-rw-r--r-- | tests/testutils.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/testutils.py b/tests/testutils.py index 8e99f04..26551d4 100644 --- a/tests/testutils.py +++ b/tests/testutils.py @@ -127,6 +127,19 @@ def skip_if_tpc_disabled(f): return skip_if_tpc_disabled_ +def skip_if_no_namedtuple(f): + def skip_if_no_namedtuple_(self): + try: + from collections import namedtuple + except ImportError: + return self.skipTest("collections.namedtuple not available") + else: + return f(self) + + skip_if_no_namedtuple_.__name__ = f.__name__ + return skip_if_no_namedtuple_ + + def skip_if_no_iobase(f): """Skip a test if io.TextIOBase is not available.""" def skip_if_no_iobase_(self): |