Use unittest 'skip' feature to skip mxDateTimeTests

Rather than deleting, the class, use the skip feature. Provides a more
informative message during test output.

Never skip DatetimeTests as all supported Python environments have the
datetime module builtin.
This commit is contained in:
Jon Dufresne 2019-03-13 06:33:01 -07:00 committed by Daniele Varrazzo
parent d411dc3a73
commit ad4c6a4673

View File

@ -447,11 +447,10 @@ class DatetimeTests(ConnectingTestCase, CommonDatetimeTestsMixin):
self.assertRaises(psycopg2.NotSupportedError, cur.fetchone)
# Only run the datetime tests if psycopg was compiled with support.
if not hasattr(psycopg2.extensions, 'PYDATETIME'):
del DatetimeTests
@unittest.skipUnless(
hasattr(psycopg2._psycopg, 'MXDATETIME'),
'Requires mx.DateTime support'
)
class mxDateTimeTests(ConnectingTestCase, CommonDatetimeTestsMixin):
"""Tests for the mx.DateTime based date handling in psycopg2."""
@ -626,14 +625,6 @@ class mxDateTimeTests(ConnectingTestCase, CommonDatetimeTestsMixin):
self._test_type_roundtrip_array(DateTimeDeltaFrom(seconds=30))
# Only run the mx.DateTime tests if psycopg was compiled with support.
try:
if not hasattr(psycopg2._psycopg, 'MXDATETIME'):
del mxDateTimeTests
except AttributeError:
del mxDateTimeTests
class FromTicksTestCase(unittest.TestCase):
# bug "TimestampFromTicks() throws ValueError (2-2.0.14)"
# reported by Jozsef Szalay on 2010-05-06