How to use with_bind_ports method in testcontainers-python

Best Python code snippet using testcontainers-python_python

containers.py

Source:containers.py Github

copy

Full Screen

...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}'...

Full Screen

Full Screen

zookeeper.py

Source:zookeeper.py Github

copy

Full Screen

...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...

Full Screen

Full Screen

conftest.py

Source:conftest.py Github

copy

Full Screen

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:...

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run testcontainers-python automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful