Best Python code snippet using testcontainers-python_python
test_db_containers.py
Source:test_db_containers.py
...12 e = sqlalchemy.create_engine(mysql.get_connection_url())13 result = e.execute("select version()")14 for row in result:15 assert row[0].startswith('5.7.17')16def test_docker_run_postgres():17 postgres_container = PostgresContainer("postgres:9.5")18 with postgres_container as postgres:19 e = sqlalchemy.create_engine(postgres.get_connection_url())20 result = e.execute("select version()")21 for row in result:22 assert row[0].lower().startswith("postgresql 9.5")23def test_docker_run_postgres_with_driver_pg8000():24 postgres_container = PostgresContainer("postgres:9.5", driver="pg8000")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())...
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!!