diff --git a/python/ciqueue/_pytest/outcomes.py b/python/ciqueue/_pytest/outcomes.py index f9e6b608..e31fec80 100644 --- a/python/ciqueue/_pytest/outcomes.py +++ b/python/ciqueue/_pytest/outcomes.py @@ -42,6 +42,14 @@ class UnserializableException(Exception): Failed: outcomes.Failed} +try: + from_exc_info = code.ExceptionInfo.from_exc_info +except AttributeError: + # pytest < 7.4 + def from_exc_info(tup): + return code.ExceptionInfo(tup) + + def swap_in_serializable(excinfo): def pickles(excinfo): try: @@ -52,14 +60,14 @@ def pickles(excinfo): if excinfo.type in SERIALIZE_TYPES: cls = SERIALIZE_TYPES[excinfo.type] tup = (cls, cls(*excinfo.value.args), excinfo.tb) - excinfo = code.ExceptionInfo(tup) + excinfo = from_exc_info(tup) elif not pickles(excinfo): tup = (UnserializableException, UnserializableException( "Actual Exception thrown on test node was %r" % excinfo.value), excinfo.tb) - excinfo = code.ExceptionInfo(tup) + excinfo = from_exc_info(tup) return excinfo @@ -67,7 +75,7 @@ def swap_back_original(excinfo): if excinfo.type in DESERIALIZE_TYPES: tipe = DESERIALIZE_TYPES[excinfo.type] tup = (tipe, tipe(*excinfo.value.args), excinfo.tb) - return code.ExceptionInfo(tup) + return from_exc_info(tup) return excinfo @@ -84,4 +92,4 @@ def failed(item): def skipped_excinfo(item, msg): traceback = list(item.error_reports.values())[0]['excinfo'].tb tup = (outcomes.Skipped, outcomes.Skipped(msg), traceback) - return code.ExceptionInfo(tup) + return from_exc_info(tup) diff --git a/python/setup.py b/python/setup.py index c7ceffef..0f546f33 100644 --- a/python/setup.py +++ b/python/setup.py @@ -37,7 +37,7 @@ def get_lua_scripts(): packages=['ciqueue', 'ciqueue._pytest'], install_requires=[ 'dill>=0.2.7', - 'pytest>=2.7,<7', + 'pytest>=2.7', 'redis>=2.10.5', 'tblib>=1.3.2', 'uritools>=2.0.0', diff --git a/python/tests/test_pytest.py b/python/tests/test_pytest.py index 3e79027c..895565ec 100644 --- a/python/tests/test_pytest.py +++ b/python/tests/test_pytest.py @@ -1,14 +1,21 @@ import os +import re import subprocess import redis +import pytest # pylint: disable=no-self-use +@pytest.fixture(autouse=True) +def change_test_dir(request, monkeypatch): + monkeypatch.chdir(request.fspath.dirname + "/..") + + def expected_messages(output): assert '= 4 failed, 2 passed, 1 skipped, 1 xpassed, 6 errors in' in output, output - assert ('integrations/pytest/test_all.py:27: skipping test message' in output - or 'integrations/pytest/test_all.py:28: skipping test message' in output), output + assert re.search(r':\d+: skipping test message', output) is not None, \ + "did not find 'skipping test message' in output" def check_output(cmd): diff --git a/python/tests/test_test_queue.py b/python/tests/test_test_queue.py index cb776162..2b85741d 100644 --- a/python/tests/test_test_queue.py +++ b/python/tests/test_test_queue.py @@ -5,10 +5,10 @@ class TestTestQueue: def test_initialise_from_redis_uri(self): queue = test_queue.build_queue('redis://localhost:6379/0?worker=1&build=12345', None) - assert type(queue) is ciqueue.distributed.Supervisor + assert isinstance(queue, ciqueue.distributed.Supervisor) assert queue.redis is not None def test_initialise_from_rediss_uri(self): queue = test_queue.build_queue('rediss://localhost:6379/0?worker=1&build=12345', None) - assert type(queue) is ciqueue.distributed.Supervisor + assert isinstance(queue, ciqueue.distributed.Supervisor) assert queue.redis is not None