Best Python code snippet using tox_python
interactive_build.py
Source:interactive_build.py
...10DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "project")11# This fixture launches a `bst build` of given element, and returns a12# `pexpect.spawn` object for the interactive session.13@pytest.fixture14def build_session(datafiles, element_name):15 project = str(datafiles)16 # Spawn interactive session using `configured()` context manager in order17 # to get the same config file as the `cli` fixture.18 with runcli.configured(project) as config_file:19 session = pexpect.spawn(20 "bst",21 ["--directory", project, "--config", config_file, "--no-colors", "build", element_name,],22 timeout=PEXPECT_TIMEOUT_SHORT,23 )24 yield session25# Verify that BuildStream exits cleanly on any of the following choices.26#27# In our simple test case, there is no practical difference between the28# following choices. In future, we'd like to test their behavior separately....
test_transport.py
Source:test_transport.py
...17 ca_trust_path='overridepath',18 )19 try:20 os.environ['REQUESTS_CA_BUNDLE'] = 'path_to_REQUESTS_CA_CERT'21 t_default.build_session()22 t_ca_override.build_session()23 assert(t_default.session.verify == 'path_to_REQUESTS_CA_CERT')24 assert(t_ca_override.session.verify == 'overridepath')25 finally:26 del os.environ['REQUESTS_CA_BUNDLE']27 try:28 os.environ['CURL_CA_BUNDLE'] = 'path_to_CURL_CA_CERT'29 t_default.build_session()30 t_ca_override.build_session()31 assert(t_default.session.verify == 'path_to_CURL_CA_CERT')32 assert (t_ca_override.session.verify == 'overridepath')33 finally:34 del os.environ['CURL_CA_BUNDLE']35def test_build_session_cert_ignore():36 t_default = Transport(endpoint="Endpoint",37 server_cert_validation='ignore',38 username='test',39 password='test',40 auth_method='basic',41 )42 t_ca_override = Transport(endpoint="Endpoint",43 server_cert_validation='ignore',44 username='test',45 password='test',46 auth_method='basic',47 ca_trust_path='boguspath'48 )49 try:50 os.environ['REQUESTS_CA_BUNDLE'] = 'path_to_REQUESTS_CA_CERT'51 os.environ['CURL_CA_BUNDLE'] = 'path_to_CURL_CA_CERT'52 t_default.build_session()53 t_ca_override.build_session()54 assert(isinstance(t_default.session.verify, bool) and not t_default.session.verify)55 assert (isinstance(t_ca_override.session.verify, bool) and not t_ca_override.session.verify)56 finally:57 del os.environ['REQUESTS_CA_BUNDLE']...
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!!