Skip to content

Commit 3047a3c

Browse files
committed
skip redis/ES tests if the required environment is missing (#561)
closes #561
1 parent 039d291 commit 3047a3c

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

tests/instrumentation/elasticsearch_tests.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,10 @@
3939

4040
from elasticapm.conf.constants import TRANSACTION
4141

42-
pytestmark = pytest.mark.elasticsearch
42+
if "ES_URL" not in os.environ:
43+
pytestmark = pytest.mark.skip("Skipping elasticsearch test, no ES_URL environment variable")
44+
else:
45+
pytestmark = pytest.mark.elasticsearch
4346

4447
document_type = "_doc" if ES_VERSION[0] >= 6 else "doc"
4548

tests/instrumentation/redis_tests.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,15 @@
4141
from elasticapm.conf.constants import TRANSACTION
4242
from elasticapm.traces import capture_span
4343

44-
pytestmark = pytest.mark.redis
44+
if "REDIS_HOST" not in os.environ:
45+
pytestmark = pytest.mark.skip("Skipping redis tests, no REDIS_HOST environment variable set")
46+
else:
47+
pytestmark = pytest.mark.redis
4548

4649

4750
@pytest.fixture()
4851
def redis_conn():
49-
conn = redis.StrictRedis(host=os.environ.get("REDIS_HOST", "localhost"), port=os.environ.get("REDIS_PORT", 6379))
52+
conn = redis.StrictRedis(host=os.environ["REDIS_HOST"], port=os.environ.get("REDIS_PORT", 6379))
5053
yield conn
5154
del conn
5255

0 commit comments

Comments
 (0)