Best Python code snippet using testcontainers-python_python
test_db_containers.py
Source:test_db_containers.py
...25 with postgres_container as postgres:26 e = sqlalchemy.create_engine(postgres.get_connection_url())27 e.execute("select 1=1")28def test_docker_run_mariadb():29 with MySqlContainer("mariadb:10.6.5").maybe_emulate_amd64() as mariadb:30 e = sqlalchemy.create_engine(mariadb.get_connection_url())31 result = e.execute("select version()")32 for row in result:33 assert row[0].startswith('10.6.5')34@pytest.mark.skip(reason="needs oracle client libraries unavailable on Travis")35def test_docker_run_oracle():36 with OracleDbContainer() as oracledb:37 e = sqlalchemy.create_engine(oracledb.get_connection_url())38 result = e.execute("select * from V$VERSION")39 versions = {'Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Production',40 'PL/SQL Release 11.2.0.2.0 - Production',41 'CORE\t11.2.0.2.0\tProduction',42 'TNS for Linux: Version 11.2.0.2.0 - Production',43 'NLSRTL Version 11.2.0.2.0 - Production'}...
test_new_docker_api.py
Source:test_new_docker_api.py
...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():24 code_dir = Path(__file__).parent25 container_first = DockerContainer("nginx:latest")26 container_first.with_volume_mapping(code_dir, '/code')27 container_second = DockerContainer("nginx:latest")28 with container_first:29 container_second.with_kwargs(volumes_from=[container_first._container.short_id])30 with container_second:31 files_first = container_first.exec('ls /code').output.decode('utf-8').strip()32 files_second = container_second.exec('ls /code').output.decode('utf-8').strip()...
test_webdriver.py
Source:test_webdriver.py
...5@pytest.mark.parametrize("caps", [DesiredCapabilities.CHROME, DesiredCapabilities.FIREFOX])6def test_webdriver_container_container(caps):7 if is_arm():8 pytest.skip('https://github.com/SeleniumHQ/docker-selenium/issues/1076')9 with BrowserWebDriverContainer(caps).maybe_emulate_amd64() as chrome:10 webdriver = chrome.get_driver()11 webdriver.get("http://google.com")...
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!!