How to use _tap_init method in autotest

Best Python code snippet using autotest_python

base_job.py

Source:base_job.py Github

copy

Full Screen

...819 # initialize all the job state820 self._state = self._job_state()821 # initialize tap reporting822 if dargs.has_key('options'):823 self._tap = self._tap_init(dargs['options'].tap_report)824 else:825 self._tap = self._tap_init(False)826 @classmethod827 def _find_base_directories(cls):828 raise NotImplementedError()829 def _initialize_dir_properties(self):830 """831 Initializes all the secondary self.*dir properties. Requires autodir,832 clientdir and serverdir to already be initialized.833 """834 # create some stubs for use as shortcuts835 def readonly_dir(*args):836 return self._job_directory(os.path.join(*args))837 def readwrite_dir(*args):838 return self._job_directory(os.path.join(*args), True)839 # various client-specific directories840 self._bindir = readonly_dir(self.clientdir, 'bin')841 self._profdir = readonly_dir(self.clientdir, 'profilers')842 self._pkgdir = readwrite_dir(self.clientdir, 'packages')843 self._toolsdir = readonly_dir(self.clientdir, 'tools')844 # directories which are in serverdir on a server, clientdir on a client845 # tmp tests, and site_tests need to be read_write for client, but only846 # read for server.847 if self.serverdir:848 root = self.serverdir849 r_or_rw_dir = readonly_dir850 else:851 root = self.clientdir852 r_or_rw_dir = readwrite_dir853 self._testdir = r_or_rw_dir(root, 'tests')854 self._site_testdir = r_or_rw_dir(root, 'site_tests')855 # various server-specific directories856 if self.serverdir:857 self._tmpdir = readwrite_dir(tempfile.gettempdir())858 else:859 self._tmpdir = readwrite_dir(root, 'tmp')860 def _find_resultdir(self, *args, **dargs):861 raise NotImplementedError()862 def push_execution_context(self, resultdir):863 """864 Save off the current context of the job and change to the given one.865 In practice method just changes the resultdir, but it may become more866 extensive in the future. The expected use case is for when a child867 job needs to be executed in some sort of nested context (for example868 the way parallel_simple does). The original context can be restored869 with a pop_execution_context call.870 @param resultdir: The new resultdir, relative to the current one.871 """872 new_dir = self._job_directory(873 os.path.join(self.resultdir, resultdir), True)874 self._execution_contexts.append(self._resultdir)875 self._resultdir = new_dir876 def pop_execution_context(self):877 """878 Reverse the effects of the previous push_execution_context call.879 @raise IndexError: raised when the stack of contexts is empty.880 """881 if not self._execution_contexts:882 raise IndexError('No old execution context to restore')883 self._resultdir = self._execution_contexts.pop()884 def get_state(self, name, default=_job_state.NO_DEFAULT):885 """Returns the value associated with a particular name.886 @param name: The name the value was saved with.887 @param default: A default value to return if no state is currently888 associated with var.889 @return: A deep copy of the value associated with name. Note that this890 explicitly returns a deep copy to avoid problems with mutable891 values; mutations are not persisted or shared.892 @raise KeyError: raised when no state is associated with var and a893 default value is not provided.894 """895 try:896 return self._state.get('public', name, default=default)897 except KeyError:898 raise KeyError(name)899 def set_state(self, name, value):900 """Saves the value given with the provided name.901 @param name: The name the value should be saved with.902 @param value: The value to save.903 """904 self._state.set('public', name, value)905 def _build_tagged_test_name(self, testname, dargs):906 """Builds the fully tagged testname and subdirectory for job.run_test.907 @param testname: The base name of the test908 @param dargs: The ** arguments passed to run_test. And arguments909 consumed by this method will be removed from the dictionary.910 @return: A 3-tuple of the full name of the test, the subdirectory it911 should be stored in, and the full tag of the subdir.912 """913 tag_parts = []914 # build up the parts of the tag used for the test name915 master_testpath = dargs.get('master_testpath', "")916 base_tag = dargs.pop('tag', None)917 if base_tag:918 tag_parts.append(str(base_tag))919 if self.use_sequence_number:920 tag_parts.append('_%02d_' % self._sequence_number)921 self._sequence_number += 1922 if self.automatic_test_tag:923 tag_parts.append(self.automatic_test_tag)924 full_testname = '.'.join([testname] + tag_parts)925 # build up the subdir and tag as well926 subdir_tag = dargs.pop('subdir_tag', None)927 if subdir_tag:928 tag_parts.append(subdir_tag)929 subdir = '.'.join([testname] + tag_parts)930 subdir = os.path.join(master_testpath, subdir)931 tag = '.'.join(tag_parts)932 return full_testname, subdir, tag933 def _make_test_outputdir(self, subdir):934 """Creates an output directory for a test to run it.935 @param subdir: The subdirectory of the test. Generally computed by936 _build_tagged_test_name.937 @return: A job_directory instance corresponding to the outputdir of938 the test.939 @raise TestError: If the output directory is invalid.940 """941 # explicitly check that this subdirectory is new942 path = os.path.join(self.resultdir, subdir)943 if os.path.exists(path):944 msg = ('%s already exists; multiple tests cannot run with the '945 'same subdirectory' % subdir)946 raise error.TestError(msg)947 # create the outputdir and raise a TestError if it isn't valid948 try:949 outputdir = self._job_directory(path, True)950 return outputdir951 except self._job_directory.JobDirectoryException, e:952 logging.exception('%s directory creation failed with %s',953 subdir, e)954 raise error.TestError('%s directory creation failed' % subdir)955 def _tap_init(self, enable):956 """Initialize TAP reporting957 """958 return TAPReport(enable, resultdir=self.resultdir)959 def record(self, status_code, subdir, operation, status='',960 optional_fields=None):961 """Record a job-level status event.962 Logs an event noteworthy to the Autotest job as a whole. Messages will963 be written into a global status log file, as well as a subdir-local964 status log file (if subdir is specified).965 @param status_code: A string status code describing the type of status966 entry being recorded. It must pass log.is_valid_status to be967 considered valid.968 @param subdir: A specific results subdirectory this also applies to, or969 None. If not None the subdirectory must exist....

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