From 3e6ed51e8b71c6ecee4ef5dd39844cef7c447905 Mon Sep 17 00:00:00 2001 From: Jason Madden Date: Fri, 11 Oct 2024 07:22:34 -0500 Subject: [PATCH] Stop using six; fixes #504. Get tests running with newer ZODB that has removed a bunch of tests apparently. --- CHANGES.rst | 2 +- src/relstorage/adapters/locker.py | 6 +----- src/relstorage/tests/hptestbase.py | 10 +++++++++- src/relstorage/tests/reltestbase.py | 13 ++++++++----- 4 files changed, 19 insertions(+), 12 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index e074a44e..0d07c139 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -9,7 +9,7 @@ to support newer compilers like GCC 13. - Compile in C++ 11 mode instead of whatever the compiler default was (sometimes C++ 03), because the latter is deprecated by Boost. - +- Stop relying on an undeclared dependency on ``six``. See :issue:`504`. 4.0.0 (2023-12-11) ================== diff --git a/src/relstorage/adapters/locker.py b/src/relstorage/adapters/locker.py index 19b8d22e..bca441a1 100644 --- a/src/relstorage/adapters/locker.py +++ b/src/relstorage/adapters/locker.py @@ -20,7 +20,6 @@ import abc import sys -import six from relstorage._compat import ABC @@ -277,10 +276,7 @@ def reraise_commit_lock_error(self, cursor, lock_stmt, kind): val = kind(message) val.__relstorage_cause__ = v del v - six.reraise( - kind, - val, - sys.exc_info()[2]) + raise val.with_traceback(sys.exc_info()[2]) # MySQL allows aggregates in the top level to use FOR UPDATE, # but PostgreSQL does not, so we have to use the second form. diff --git a/src/relstorage/tests/hptestbase.py b/src/relstorage/tests/hptestbase.py index 8a3c497e..cd62b917 100644 --- a/src/relstorage/tests/hptestbase.py +++ b/src/relstorage/tests/hptestbase.py @@ -480,6 +480,9 @@ def __tid_clock_needs_care(self): return getattr(adapter, 'RS_TEST_TXN_PACK_NEEDS_SLEEP', False) def __maybe_ignore_monotonic(self, cls, method_name): + if not hasattr(super(), method_name): + raise unittest.SkipTest('Method ' + method_name + ' not available') + if not self.__tid_clock_needs_care(): return getattr(super(), method_name)() @@ -523,6 +526,8 @@ def checkLoadBeforeOld(self): 'checkLoadBeforeOld') def checkSimpleHistory(self): + if not hasattr(super(), 'checkSimpleHistory'): + raise unittest.SkipTest('No test checkSimpleHistory') if not self.__tid_clock_needs_care(): return super().checkSimpleHistory() # pylint:disable=no-member # This assumes that the `time` value in the storage.history() @@ -605,7 +610,10 @@ def _run_with_storage_packing_at_packtime(self, find_packtime): # Ignore the pack timestamp given. Execute `find_packtime(storage)` # instead and use that. - meth = getattr(super(), methname) + try: + meth = getattr(super(), methname) + except AttributeError: + raise unittest.SkipTest('No method ' + methname) from None if not self.__tid_clock_needs_care(): return meth() diff --git a/src/relstorage/tests/reltestbase.py b/src/relstorage/tests/reltestbase.py index 96841f1e..c3392f73 100644 --- a/src/relstorage/tests/reltestbase.py +++ b/src/relstorage/tests/reltestbase.py @@ -225,9 +225,12 @@ def __thread_safe_wrapper(self): self._storage = orig_storage def __generic_wrapped_test(self, meth_name): - meth = getattr( - super(), - meth_name) + try: + meth = getattr( + super(), + meth_name) + except AttributeError: + self.skipTest('No method ' + meth_name) try: with self.__thread_safe_wrapper(): meth() @@ -1119,11 +1122,11 @@ def checkBTreesLengthStress(self): # pylint:disable=too-complex from ZODB.ConflictResolution import logger as CRLogger from BTrees.Length import Length import BTrees - from six import reraise def log_err(*args, **kwargs): # pylint:disable=unused-argument import sys - reraise(*sys.exc_info()) + _t, v, _tb = sys.exc_info() + raise v CRLogger.debug = log_err CRLogger.exception = log_err