Best Python code snippet using testcontainers-python_python
containers.py
Source:containers.py
...22 return url23class S3MockContainer(DockerContainer):24 def __init__(self, image='adobe/s3mock:latest', initial_bucket='test', root='/tmp/buckets', http_port=9090, https_port=9191, **kwargs):25 super().__init__(image, **kwargs)26 self.with_bind_ports(http_port, http_port)27 self.with_bind_ports(https_port, https_port)28 self.with_env('initialBuckets', initial_bucket)29 self.with_env('root', root)30 self.initial_bucket = initial_bucket31 self.root = root32 self.http_port = http_port33 self.https_port = https_port34 def get_initial_bucket(self):35 return self.initial_bucket36 def get_http_endpoint(self):37 return f'http://localhost:{self.http_port}'38 def get_https_endpoint(self):39 return f'http://localhost:{self.https_port}'40 def get_http_endpoint_for_docker_network(self):41 return f'http://{self._name}:{self.http_port}'...
zookeeper.py
Source:zookeeper.py
...10 Args:11 image (str, optional): Used Docker image. Defaults to debezium/zookeeper:1.7.1.Final.12 """13 super(ZookeeperContainer, self).__init__(image)14 self.with_bind_ports(2181, 2181)15 self.with_bind_ports(2888, 2888)16 self.with_bind_ports(3888, 3888)17 self.with_name("zookeper")18 self.with_kwargs(19 hostname="zookeper"20 )21 def start(self, timeout=60):22 """Starts the Zookeeper and waits for it to be ready.23 Args:24 timeout (int, optional): Timeout for container to be ready. Defaults to 60.25 """26 super().start()27 wait_for_logs(self, r'binding to port', timeout=timeout)28 return self29 def get_zookeeper_url(self):30 """Returns Zookeeper's URL...
conftest.py
Source:conftest.py
1import pytest2from testcontainers.postgres import PostgresContainer3@pytest.fixture(scope="session", autouse=True)4def postgres() -> None:5 with PostgresContainer("postgres:13.3").with_bind_ports(5432, 5432) as pg:...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!