diff --git a/tests/test_dates.py b/tests/test_dates.py index 95f40907..fdc28742 100755 --- a/tests/test_dates.py +++ b/tests/test_dates.py @@ -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