Skip to content

Commit b67c2aa

Browse files
authored
Limit usage of testcontainers. (#35921)
* Limit usage of testcontainers. * Update sdks/python/conftest.py * Update sdks/python/conftest.py * Update sdks/python/conftest.py
1 parent 701919e commit b67c2aa

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

sdks/python/conftest.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
from types import SimpleNamespace
2323

2424
import pytest
25-
from testcontainers.core import waiting_utils
2625

2726
from apache_beam.options import pipeline_options
2827
from apache_beam.testing.test_pipeline import TestPipeline
@@ -162,12 +161,16 @@ def pytest_configure(config):
162161
"""
163162
# for the entire test session.
164163
print("\n--- Applying global testcontainers timeout configuration ---")
165-
waiting_utils.config = SimpleNamespace(
166-
timeout=int(os.getenv("TC_TIMEOUT", "120")),
167-
max_tries=int(os.getenv("TC_MAX_TRIES", "120")),
168-
sleep_time=float(os.getenv("TC_SLEEP_TIME", "1")),
169-
)
170-
print("Successfully set waiting utils config")
164+
try:
165+
from testcontainers.core import waiting_utils
166+
waiting_utils.config = SimpleNamespace(
167+
timeout=int(os.getenv("TC_TIMEOUT", "120")),
168+
max_tries=int(os.getenv("TC_MAX_TRIES", "120")),
169+
sleep_time=float(os.getenv("TC_SLEEP_TIME", "1")),
170+
)
171+
print("Successfully set waiting utils config")
172+
except ModuleNotFoundError:
173+
print("The testcontainers library is not installed.")
171174

172175
TestPipeline.pytest_test_pipeline_options = config.getoption(
173176
'test_pipeline_options', default='')

0 commit comments

Comments
 (0)