Best Python code snippet using testcontainers-python_python
container.py
Source:container.py
...27 for port in list(ports):28 self.ports[port] = None29 return self30 @deprecated(details='Use `with_kwargs`.')31 def with_kargs(self, **kargs) -> 'DockerContainer':32 return self.with_kwargs(**kargs)33 def with_kwargs(self, **kwargs) -> 'DockerContainer':34 self._kwargs = kwargs35 return self36 def maybe_emulate_amd64(self) -> 'DockerContainer':37 if is_arm():38 return self.with_kwargs(platform='linux/amd64')39 return self40 def start(self):41 logger.info("Pulling image %s", self.image)42 docker_client = self.get_docker_client()43 self._container = docker_client.run(self.image,44 command=self._command,45 detach=True,...
conftest.py
Source:conftest.py
...15@pytest.fixture(scope='session')16def dind():17 with (TestContainer('docker:dind')18 .with_env('DOCKER_TLS_CERTDIR', '')19 .with_kargs(privileged=True)20 .with_exposed_ports(DAEMON_PORT)21 .with_bind_ports(EXTERNAL_REGISTRY_PORT, EXTERNAL_REGISTRY_PORT)) as daemon:22 time.sleep(1)23 yield daemon24@pytest.fixture(scope='session')25def docker_daemon(dind):26 return DockerDaemon(f'localhost:{dind.get_exposed_port(DAEMON_PORT)}')27@pytest.fixture(scope='session')28def docker_registry(dind, docker_daemon):29 with docker_daemon.client() as c:30 c: docker.DockerClient31 c.containers.run('registry:latest', ports={INTERNAL_REGISTRY_PORT: EXTERNAL_REGISTRY_PORT},32 detach=True, remove=True,33 environment={'REGISTRY_STORAGE_DELETE_ENABLED': 'true'})...
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!!