Best Python code snippet using testcontainers-python_python
transactions.py
Source:transactions.py
...93 self.cur1.execute("insert into test(i) values (5)")94 self.cur2.execute("select i from test")95 res = self.cur2.fetchall()96 self.assertEqual(len(res), 1)97 def test_raise_timeout(self):98 self.cur1.execute("create table test(i)")99 self.cur1.execute("insert into test(i) values (5)")100 with self.assertRaises(sqlite.OperationalError):101 self.cur2.execute("insert into test(i) values (5)")102 def test_locking(self):103 """104 This tests the improved concurrency with pysqlite 2.3.4. You needed105 to roll back con2 before you could commit con1.106 """107 self.cur1.execute("create table test(i)")108 self.cur1.execute("insert into test(i) values (5)")109 with self.assertRaises(sqlite.OperationalError):110 self.cur2.execute("insert into test(i) values (5)")111 # NO self.con2.rollback() HERE!!!...
test_core.py
Source:test_core.py
1import pytest2from testcontainers.core.container import DockerContainer3from testcontainers.core.waiting_utils import wait_for_logs4def test_raise_timeout():5 with pytest.raises(TimeoutError):6 with DockerContainer("alpine").with_command("sleep 2") as container:7 wait_for_logs(container, "Hello from Docker!", timeout=1e-3)8def test_wait_for_hello():9 with DockerContainer("hello-world") as container:10 wait_for_logs(container, "Hello from Docker!")11def test_can_get_logs():12 with DockerContainer("hello-world") as container:13 wait_for_logs(container, "Hello from Docker!")14 stdout, stderr = container.get_logs()...
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!!