Best Python code snippet using localstack_python
test_build.py
Source:test_build.py
1from common import * # NOQA2TEST_BUILD = os.environ.get('TEST_BUILD', 'false')3if_test_build = pytest.mark.skipif(4 TEST_BUILD != "true",5 reason='TEST_BUILD is set to false')6@if_test_build7def test_run_build(pipeline_resource):8 test_registry_server = os.environ.get('TEST_REG_SERVER')9 test_registry_username = os.environ.get('TEST_REG_USERNAME')10 test_registry_password = os.environ.get('TEST_REG_PASSWORD')11 test_build_image = os.environ.get('TEST_BUILD_IMAGE')12 if test_registry_server is None or test_registry_username is None or \13 test_registry_password is None or test_build_image is None:14 print 'No registry credential passed to test build'15 assert 016 else:17 if get_registry(test_registry_server) is None:18 create_registry(test_registry_server,19 test_registry_username,20 test_registry_password)21 stages = [22 {23 "name": "SCM",24 "steps": [{25 "branch": "master",26 "repository": "https://github.com/gitlawr/php.git",27 "type": "scm"}]28 },29 {30 "name": "buildfromsource",31 "steps": [32 {33 "dockerfilePath": "./",34 "targetImage": test_build_image,35 "type": "build"}]36 },37 {38 "name": "buildfromfile",39 "steps": [{40 "dockerfilePath": "./",41 "file": "FROM alpine\n\nRUN echo test \u003e /myfile",42 "targetImage": test_build_image,43 "type": "build"}]44 },45 {46 "name": "push",47 "steps": [{48 "dockerfilePath": "./",49 "push": True,50 "targetImage": test_build_image,51 "type": "build"}]52 }]53 create_pipeline(name='buildtest', stages=stages)54 run_pipeline_expect('buildtest', 'Success', 300)55 remove_pipeline('buildtest')56@if_test_build57def test_run_pipeline_build_fail_no_credential(pipeline_resource):58 stages = [59 {60 "name": "SCM",61 "steps": [{62 "branch": "master",63 "repository": "https://github.com/gitlawr/php.git",64 "type": "scm"}]65 },66 {67 "name": "buildfromsource",68 "steps": [69 {70 "dockerfilePath": "./",71 "push": True,72 "targetImage": "nonexist.com/myimage:mytag",73 "type": "build"}]74 }]75 create_pipeline(name='buildfailpushtest', stages=stages)76 run_pipeline_expect('buildfailpushtest', 'Fail', 300)...
test_html.py
Source:test_html.py
1# -*- coding: utf-8 -*-2from sphinx_testing import with_app3@with_app(srcdir='docs', buildername='html')4def test_build_image(app, status, warning):5 app.build()6 html = (app.outdir / 'index.html').read_text(encoding='utf-8')7 print(html)8 assert '<img alt="regular inclusion" src="_images/test.svg" />' in html9 assert '<object alt="tagtype absent" data="_images/test.svg" type="image/svg+xml">' in html10 assert '<object alt="tagtype object" data="_images/test.svg" type="image/svg+xml">' in html...
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!!