Best Python code snippet using testcontainers-python_python
test_new_docker_api.py
Source:test_new_docker_api.py
...5from testcontainers.core.container import DockerContainer6def setup_module(m):7 os.environ["MYSQL_USER"] = "demo"8 os.environ["MYSQL_DATABASE"] = "custom_db"9def test_docker_custom_image():10 container = DockerContainer("mysql:5.7.17")11 container.with_exposed_ports(3306)12 container.with_env("MYSQL_ROOT_PASSWORD", "root")13 with container:14 port = container.get_exposed_port(3306)15 assert int(port) > 016def test_docker_env_variables():17 container = mysql.MySqlContainer("mariadb:10.6.5")\18 .with_bind_ports(3306, 32785).maybe_emulate_amd64()19 with container:20 url = container.get_connection_url()21 pattern = r'mysql\+pymysql:\/\/demo:test@[\w,.]+:(3306|32785)\/custom_db'22 assert re.match(pattern, url)23def test_docker_kwargs():...
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!!