Skip to content

Commit 92abab2

Browse files
committed
tests/integration: Switch new decorators to pytest.mark.xfail
It has some advantages, explained in the comment them. For completeness, I'm copying this comment here: # pytest.mark.xfail instead of unittest.expectedFailure because # 1. unittest doesn't skip setUpClass when used on class and we need it sometimes # 2. unittest doesn't have conditional xfail, and I prefer to use pytest than custom decorator # 3. unittest doesn't have a reason argument, so you don't see the reason in pytest report In the future all decorators should probably be switched over.
1 parent 2c00eeb commit 92abab2

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

tests/integration/__init__.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
from itertools import groupby
3535
import six
3636
import shutil
37+
import pytest
3738

3839

3940
from cassandra import OperationTimedOut, ReadTimeout, ReadFailure, WriteTimeout, WriteFailure, AlreadyExists,\
@@ -366,8 +367,14 @@ def _id_and_mark(f):
366367
lessthandse51 = unittest.skipUnless(DSE_VERSION and DSE_VERSION < Version('5.1'), "DSE version less than 5.1 required")
367368
lessthandse60 = unittest.skipUnless(DSE_VERSION and DSE_VERSION < Version('6.0'), "DSE version less than 6.0 required")
368369

369-
requires_collection_indexes = unittest.skipUnless(SCYLLA_VERSION is None or Version(SCYLLA_VERSION.split(':')[1]) >= Version('5.2'), 'Test requires Scylla >= 5.2 or Cassandra')
370-
requires_custom_indexes = unittest.skipUnless(SCYLLA_VERSION is None, 'Currently, Scylla does not support SASI or any other CUSTOM INDEX class.')
370+
# pytest.mark.xfail instead of unittest.expectedFailure because
371+
# 1. unittest doesn't skip setUpClass when used on class and we need it sometimes
372+
# 2. unittest doesn't have conditional xfail, and I prefer to use pytest than custom decorator
373+
# 3. unittest doesn't have a reason argument, so you don't see the reason in pytest report
374+
requires_collection_indexes = pytest.mark.xfail(SCYLLA_VERSION is not None and Version(SCYLLA_VERSION.split(':')[1]) < Version('5.2'),
375+
reason='Scylla supports collection indexes from 5.2 onwards')
376+
requires_custom_indexes = pytest.mark.xfail(SCYLLA_VERSION is not None,
377+
reason='Scylla does not support SASI or any other CUSTOM INDEX class')
371378

372379
pypy = unittest.skipUnless(platform.python_implementation() == "PyPy", "Test is skipped unless it's on PyPy")
373380
notpy3 = unittest.skipIf(sys.version_info >= (3, 0), "Test not applicable for Python 3.x runtime")

0 commit comments

Comments
 (0)