mirror of
https://github.com/psycopg/psycopg2.git
synced 2025-01-31 09:24:07 +03:00
Fixed bytea encoding tests skipping when ctypes is not available
This commit is contained in:
parent
7716cc6a0c
commit
2dab7d52f2
|
@ -28,7 +28,7 @@ except:
|
|||
pass
|
||||
import sys
|
||||
import testutils
|
||||
from testutils import unittest
|
||||
from testutils import unittest, decorate_all_tests
|
||||
from testconfig import dsn
|
||||
|
||||
import psycopg2
|
||||
|
@ -333,8 +333,8 @@ class ByteaParserTest(unittest.TestCase):
|
|||
try:
|
||||
self._cast = self._import_cast()
|
||||
except Exception, e:
|
||||
return self.skipTest("can't test bytea parser: %s - %s"
|
||||
% (e.__class__.__name__, e))
|
||||
self._cast = None
|
||||
self._exc = e
|
||||
|
||||
def _import_cast(self):
|
||||
"""Use ctypes to access the C function.
|
||||
|
@ -412,6 +412,18 @@ class ByteaParserTest(unittest.TestCase):
|
|||
|
||||
self.assertEqual(rv, tgt)
|
||||
|
||||
def skip_if_cant_cast(f):
|
||||
def skip_if_cant_cast_(self, *args, **kwargs):
|
||||
if self._cast is None:
|
||||
return self.skipTest("can't test bytea parser: %s - %s"
|
||||
% (self._exc.__class__.__name__, self._exc))
|
||||
|
||||
return f(self, *args, **kwargs)
|
||||
|
||||
return skip_if_cant_cast_
|
||||
|
||||
decorate_all_tests(ByteaParserTest, skip_if_cant_cast)
|
||||
|
||||
|
||||
def test_suite():
|
||||
return unittest.TestLoader().loadTestsFromName(__name__)
|
||||
|
|
Loading…
Reference in New Issue
Block a user