Best Python code snippet using testcontainers-python_python
testcontainer.py
Source:testcontainer.py
...27 self.with_env("POSTGRES_USER", self.POSTGRES_USER)28 self.with_env("POSTGRES_PASSWORD", self.POSTGRES_PASSWORD)29 self.with_env("POSTGRES_DB", self.POSTGRES_DB)30 def get_connection_url(self):31 return super()._create_connection_url(dialect="postgresql+pg8000",32 username=self.POSTGRES_USER,33 password=self.POSTGRES_PASSWORD,34 db_name=self.POSTGRES_DB,35 port=self.port_to_expose)36def create_postgres_container(db_name, db_username, db_password, db_port):37 """38 Returns a new PortablePostgresContainer instance39 """40 log.msg(41 'testcontainers/create',42 db_name=db_name,43 db_username=db_username,44 db_port=db_port45 )...
__init__.py
Source:__init__.py
...8def get_session(config):9 global _session10 if _session is not None:11 return _session12 url = _create_connection_url(config)13 engine = sqlalchemy.create_engine(url, poolclass=sqlalchemy.pool.NullPool, echo=False)14 _session = sqlalchemy.orm.sessionmaker()15 _session.configure(bind=engine)16 _session = _session()17 return _session18def close_connection():19 global _session20 if _session is not None:21 _session.close()22def _create_connection_url(config):23 hostname = config.get('hostname')24 port = config.get('port', '5432')25 username = config.get('username')26 password = config.get('password')27 database = config.get('database', 'mitro')28 conn = 'postgres://'29 if username:30 conn += username31 if password and username:32 conn += ':' + password33 if password or username:34 conn += '@'35 if hostname:36 conn += hostname...
oracle.py
Source:oracle.py
...14 self.container_port = 152115 self.with_exposed_ports(self.container_port)16 self.with_env("ORACLE_ALLOW_REMOTE", "true")17 def get_connection_url(self):18 return super()._create_connection_url(19 dialect="oracle", username="system", password="oracle", port=self.container_port,20 db_name="xe"21 )22 def _configure(self):...
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!!