Skip to content

Commit 4f26369

Browse files
committed
Fix up pytest skip markers
1 parent aace788 commit 4f26369

File tree

3 files changed

+16
-30
lines changed

3 files changed

+16
-30
lines changed

tests/datastore_elasticsearch/conftest.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,15 @@
3434
linked_applications=["Python Agent Test (datastore)"],
3535
)
3636

37-
ES_VERSION = get_package_version_tuple("elasticsearch")
3837
ES_SETTINGS = elasticsearch_settings()[0]
3938
ES_MULTIPLE_SETTINGS = elasticsearch_settings()
4039
ES_URL = f"http://{ES_SETTINGS['host']}:{ES_SETTINGS['port']}"
40+
ES_VERSION = get_package_version_tuple("elasticsearch")
41+
42+
IS_V8_OR_ABOVE = ES_VERSION >= (8,)
43+
IS_V7_OR_BELOW = not IS_V8_OR_ABOVE
44+
RUN_IF_V8_OR_ABOVE = pytest.mark.skipif(not IS_V8_OR_ABOVE, reason="Unsupported for elasticsearch>=8")
45+
RUN_IF_V7_OR_BELOW = pytest.mark.skipif(not IS_V7_OR_BELOW, reason="Unsupported for elasticsearch<=7")
4146

4247

4348
@pytest.fixture(scope="function")

tests/datastore_elasticsearch/test_async_transport.py

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# limitations under the License.
1414

1515
import pytest
16-
from conftest import ES_SETTINGS, ES_URL, ES_VERSION
16+
from conftest import ES_SETTINGS, ES_URL, ES_VERSION, RUN_IF_V8_OR_ABOVE
1717
from testing_support.util import instance_hostname
1818
from testing_support.validators.validate_transaction_errors import validate_transaction_errors
1919
from testing_support.validators.validate_transaction_metrics import validate_transaction_metrics
@@ -31,15 +31,6 @@
3131

3232
HttpxAsyncHttpNode = None # Not implemented in v7
3333

34-
35-
IS_V8 = ES_VERSION >= (8,)
36-
IS_V7 = ES_VERSION >= (7,) and ES_VERSION < (8, 0)
37-
IS_BELOW_V7 = ES_VERSION < (7,)
38-
39-
RUN_IF_V8 = pytest.mark.skipif(IS_V7 or IS_BELOW_V7, reason="Only run for v8+")
40-
RUN_IF_V7 = pytest.mark.skipif(IS_V8 or IS_BELOW_V7, reason="Only run for v7")
41-
RUN_IF_BELOW_V7 = pytest.mark.skipif(not IS_BELOW_V7, reason="Only run for versions below v7")
42-
4334
HOST = instance_hostname(ES_SETTINGS["host"])
4435
PORT = ES_SETTINGS["port"]
4536

@@ -56,9 +47,8 @@ async def _exercise_es(es):
5647
@pytest.mark.parametrize(
5748
"client_kwargs",
5849
[
59-
pytest.param({"node_class": AIOHttpConnection}, id="AIOHttpConnectionV8", marks=RUN_IF_V8),
60-
pytest.param({"node_class": HttpxAsyncHttpNode}, id="HttpxAsyncHttpNodeV8", marks=RUN_IF_V8),
61-
pytest.param({"node_class": AIOHttpConnection}, id="AIOHttpConnectionV7", marks=RUN_IF_V7),
50+
pytest.param({"node_class": HttpxAsyncHttpNode}, id="HttpxAsyncHttpNodeV8", marks=RUN_IF_V8_OR_ABOVE),
51+
pytest.param({"node_class": AIOHttpConnection}, id="AIOHttpConnection"),
6252
],
6353
)
6454
@validate_transaction_errors(errors=[])

tests/datastore_elasticsearch/test_transport.py

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# limitations under the License.
1414

1515
import pytest
16-
from conftest import ES_SETTINGS, ES_URL, ES_VERSION
16+
from conftest import ES_SETTINGS, ES_URL, ES_VERSION, RUN_IF_V7_OR_BELOW, RUN_IF_V8_OR_ABOVE
1717
from testing_support.util import instance_hostname
1818
from testing_support.validators.validate_transaction_errors import validate_transaction_errors
1919
from testing_support.validators.validate_transaction_metrics import validate_transaction_metrics
@@ -33,15 +33,6 @@
3333

3434
NodeConfig = dict
3535

36-
37-
IS_V8 = ES_VERSION >= (8,)
38-
IS_V7 = ES_VERSION >= (7,) and ES_VERSION < (8, 0)
39-
IS_BELOW_V7 = ES_VERSION < (7,)
40-
41-
RUN_IF_V8 = pytest.mark.skipif(IS_V7 or IS_BELOW_V7, reason="Only run for v8+")
42-
RUN_IF_V7 = pytest.mark.skipif(IS_V8 or IS_BELOW_V7, reason="Only run for v7")
43-
RUN_IF_BELOW_V7 = pytest.mark.skipif(not IS_BELOW_V7, reason="Only run for versions below v7")
44-
4536
HOST = instance_hostname(ES_SETTINGS["host"])
4637
PORT = ES_SETTINGS["port"]
4738

@@ -59,14 +50,14 @@ def _exercise_es(es):
5950
"client_kwargs",
6051
[
6152
pytest.param({}, id="DefaultTransport"),
62-
pytest.param({"connection_class": Urllib3HttpConnection}, id="Urllib3HttpConnectionv7", marks=RUN_IF_BELOW_V7),
6353
pytest.param(
64-
{"connection_class": RequestsHttpConnection}, id="RequestsHttpConnectionv7", marks=RUN_IF_BELOW_V7
54+
{"connection_class": Urllib3HttpConnection}, id="Urllib3HttpConnectionv7", marks=RUN_IF_V7_OR_BELOW
55+
),
56+
pytest.param(
57+
{"connection_class": RequestsHttpConnection}, id="RequestsHttpConnectionv7", marks=RUN_IF_V7_OR_BELOW
6558
),
66-
pytest.param({"connection_class": Urllib3HttpConnection}, id="Urllib3HttpConnectionv7", marks=RUN_IF_V7),
67-
pytest.param({"connection_class": RequestsHttpConnection}, id="RequestsHttpConnectionv7", marks=RUN_IF_V7),
68-
pytest.param({"node_class": Urllib3HttpConnection}, id="Urllib3HttpNodev8", marks=RUN_IF_V8),
69-
pytest.param({"node_class": RequestsHttpConnection}, id="RequestsHttpNodev8", marks=RUN_IF_V8),
59+
pytest.param({"node_class": Urllib3HttpConnection}, id="Urllib3HttpNodev8", marks=RUN_IF_V8_OR_ABOVE),
60+
pytest.param({"node_class": RequestsHttpConnection}, id="RequestsHttpNodev8", marks=RUN_IF_V8_OR_ABOVE),
7061
],
7162
)
7263
@validate_transaction_errors(errors=[])

0 commit comments

Comments
 (0)