Best Python code snippet using autotest_python
test_importer.py
Source:test_importer.py  
...190            path=test.replace(autotest_dir, '').lstrip('/'))[0]191        logging.info("Processing %s", new_test.path)192        # Set the test's attributes193        data = tests[test]194        _set_attributes_clean(new_test, data)195        # Custom Attribute Update196        if site_set_attributes_module:197            site_set_attributes_module._set_attributes_custom(new_test, data)198        # This only takes place if --add-noncompliant is provided on the CLI199        if not new_test.name:200            test_new_test = test.split('/')201            if test_new_test[-1] == 'control':202                new_test.name = test_new_test[-2]203            else:204                control_name = "%s:%s"205                control_name %= (test_new_test[-2],206                                 test_new_test[-1])207                new_test.name = control_name.replace('control.', '')208        # Experimental Check209        if not add_experimental and new_test.experimental:210            continue211        _log_or_execute(repr(new_test), new_test.save)212        add_label_dependencies(new_test)213        # save TestParameter214        for para_name in data.test_parameters:215            test_parameter = models.TestParameter.objects.get_or_create(216                test=new_test, name=para_name)[0]217            test_parameter.save()218def _set_attributes_clean(test, data):219    """220    First pass sets the attributes of the Test object from file system.221    :param test: a test object to be populated for the database.222    :param data: object with test data from the file system.223    """224    test_type = {'client': 1,225                 'server': 2}226    test_time = {'short': 1,227                 'medium': 2,228                 'long': 3}229    test.test_type = test_type[data.test_type.lower()]230    test.test_time = test_time[data.time.lower()]231    string_attributes = ('name', 'author', 'test_class', 'test_category',232                         'test_category', 'sync_count')...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!!
