How to use _installtest method in autotest

Best Python code snippet using autotest_python

test.py

Source:test.py Github

copy

Full Screen

...440 # no func accepts *dargs, so:441 for param in dargs:442 if not param in all_varnames:443 raise error.AutotestError('Unknown parameter: %s' % param)444def _installtest(job, url):445 (group, name) = job.pkgmgr.get_package_name(url, 'test')446 # Bail if the test is already installed447 group_dir = os.path.join(job.testdir, "download", group)448 if os.path.exists(os.path.join(group_dir, name)):449 return (group, name)450 # If the group directory is missing create it and add451 # an empty __init__.py so that sub-directories are452 # considered for import.453 if not os.path.exists(group_dir):454 os.makedirs(group_dir)455 f = file(os.path.join(group_dir, '__init__.py'), 'w+')456 f.close()457 print name + ": installing test url=" + url458 tarball = os.path.basename(url)459 tarball_path = os.path.join(group_dir, tarball)460 test_dir = os.path.join(group_dir, name)461 job.pkgmgr.fetch_pkg(tarball, tarball_path,462 repo_url = os.path.dirname(url))463 # Create the directory for the test464 if not os.path.exists(test_dir):465 os.mkdir(os.path.join(group_dir, name))466 job.pkgmgr.untar_pkg(tarball_path, test_dir)467 os.remove(tarball_path)468 # For this 'sub-object' to be importable via the name469 # 'group.name' we need to provide an __init__.py,470 # so link the main entry point to this.471 os.symlink(name + '.py', os.path.join(group_dir, name,472 '__init__.py'))473 # The test is now installed.474 return (group, name)475def _call_test_function(func, *args, **dargs):476 """Calls a test function and translates exceptions so that errors477 inside test code are considered test failures."""478 try:479 return func(*args, **dargs)480 except error.AutotestError:481 # Pass already-categorized errors on up as is.482 raise483 except Exception, e:484 # Other exceptions must be treated as a FAIL when485 # raised during the test functions486 raise error.UnhandledTestFail(e)487def runtest(job, url, tag, args, dargs,488 local_namespace={}, global_namespace={},489 before_test_hook=None, after_test_hook=None,490 before_iteration_hook=None, after_iteration_hook=None):491 local_namespace = local_namespace.copy()492 global_namespace = global_namespace.copy()493 # if this is not a plain test name then download and install the494 # specified test495 if url.endswith('.tar.bz2'):496 (testgroup, testname) = _installtest(job, url)497 bindir = os.path.join(job.testdir, 'download', testgroup, testname)498 importdir = os.path.join(job.testdir, 'download')499 site_bindir = None500 modulename = '%s.%s' % (re.sub('/', '.', testgroup), testname)501 classname = '%s.%s' % (modulename, testname)502 path = testname503 else:504 # If the test is local, it may be under either testdir or site_testdir.505 # Tests in site_testdir override tests defined in testdir506 testname = path = url507 testgroup = ''508 path = re.sub(':', '/', testname)509 modulename = os.path.basename(path)510 classname = '%s.%s' % (modulename, modulename)...

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run autotest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful