Best Python code snippet using avocado_python
test_plugin_vmimage.py
Source:test_plugin_vmimage.py
...19class VMImagePlugin(unittest.TestCase):20 @unittest.skipUnless(os.environ.get('AVOCADO_SELFTESTS_NETWORK_ENABLED', False),21 "Network required to run these tests")22 def setUp(self):23 (self.base_dir, self.mapping, self.config_file) = get_temporary_config(24 __name__, self, 'setUp')25 @unittest.skipIf(missing_binary('qemu-img'),26 "QEMU disk image utility is required by the vmimage utility ")27 def test_download_image(self):28 expected_output = "Fedora-Cloud-Base-30-1.2.x86_64.qcow2"29 image_dir = os.path.join(self.mapping['cache_dir'], 'by_location',30 '89b7a3293bbc1dd73bb143b15fa06f0f9c7188b8')31 os.makedirs(image_dir)32 open(os.path.join(image_dir, expected_output), "w").close()33 cmd_line = "%s --config %s vmimage get --distro fedora --distro-version " \34 "30 --arch x86_64" % (AVOCADO, self.config_file.name)35 result = process.run(cmd_line)36 self.assertIn(expected_output, result.stdout_text)37 def test_download_image_fail(self):...
common.py
Source:common.py
2import os.path as p3import shutil4import tempfile5from markdoc.config import Config6def get_temporary_config():7 8 """9 Return a temporary Markdoc configuration.10 11 The contents of the wiki will be copied from the example Markdoc wiki. After12 you're done with this, you should call `clean_temporary_config()` on the13 config object.14 """15 16 own_config_dir = p.join(p.dirname(p.abspath(__file__)), 'example') + p.sep17 temp_config_dir = p.join(tempfile.mkdtemp(), 'example')18 shutil.copytree(own_config_dir, temp_config_dir)19 return Config.for_directory(temp_config_dir)20def clean_temporary_config(config):...
builder_fixture.py
Source:builder_fixture.py
1# -*- coding: utf-8 -*-2import os.path as p3from common import get_temporary_config, clean_temporary_config4def setup_test(test):5 test.globs['CONFIG'] = get_temporary_config()6 test.globs['WIKI_ROOT'] = p.join(test.globs['CONFIG']['meta.root'], '')7def teardown_test(test):...
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!!