How to use _unique_subdirectory method in autotest

Best Python code snippet using autotest_python

server_job.py

Source:server_job.py Github

copy

Full Screen

...628 break629 # sort into timestamp order630 warnings.sort()631 return warnings632 def _unique_subdirectory(self, base_subdirectory_name):633 """Compute a unique results subdirectory based on the given name.634 Appends base_subdirectory_name with a number as necessary to find a635 directory name that doesn't already exist.636 """637 subdirectory = base_subdirectory_name638 counter = 1639 while os.path.exists(os.path.join(self.resultdir, subdirectory)):640 subdirectory = base_subdirectory_name + '.' + str(counter)641 counter += 1642 return subdirectory643 def get_record_context(self):644 """Returns an object representing the current job.record context.645 The object returned is an opaque object with a 0-arg restore method646 which can be called to restore the job.record context (i.e. indentation)647 to the current level. The intention is that it should be used when648 something external which generate job.record calls (e.g. an autotest649 client) can fail catastrophically and the server job record state650 needs to be reset to its original "known good" state.651 :return: A context object with a 0-arg restore() method."""652 return self._indenter.get_context()653 def record_summary(self, status_code, test_name, reason='', attributes=None,654 distinguishing_attributes=(), child_test_ids=None):655 """Record a summary test result.656 :param status_code: status code string, see657 shared.log.is_valid_status()658 :param test_name: name of the test659 :param reason: (optional) string providing detailed reason for test660 outcome661 :param attributes: (optional) dict of string keyvals to associate with662 this result663 :param distinguishing_attributes: (optional) list of attribute names664 that should be used to distinguish identically-named test665 results. These attributes should be present in the attributes666 parameter. This is used to generate user-friendly subdirectory667 names.668 :param child_test_ids: (optional) list of test indices for test results669 used in generating this result.670 """671 subdirectory_name_parts = [test_name]672 for attribute in distinguishing_attributes:673 assert attributes674 assert attribute in attributes, '%s not in %s' % (attribute,675 attributes)676 subdirectory_name_parts.append(attributes[attribute])677 base_subdirectory_name = '.'.join(subdirectory_name_parts)678 subdirectory = self._unique_subdirectory(base_subdirectory_name)679 subdirectory_path = os.path.join(self.resultdir, subdirectory)680 os.mkdir(subdirectory_path)681 self.record(status_code, subdirectory, test_name,682 status=reason, optional_fields={'is_summary': True})683 if attributes:684 utils.write_keyval(subdirectory_path, attributes)685 if child_test_ids:686 ids_string = ','.join(str(test_id) for test_id in child_test_ids)687 summary_data = {'child_test_ids': ids_string}688 utils.write_keyval(os.path.join(subdirectory_path, 'summary_data'),689 summary_data)690 def disable_warnings(self, warning_type):691 self.warning_manager.disable_warnings(warning_type)692 self.record("INFO", None, None,...

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