Best Python code snippet using autotest_python
control_file.py
Source:control_file.py  
...116                line = line[match.end():]117            else:118                break119    return '\n'.join(res)120def _get_profiler_commands(profilers, is_server, profile_only):121    prepend, append = [], []122    if profile_only is not None:123        prepend.append("job.default_profile_only = %r" % profile_only)124    for profiler in profilers:125        prepend.append("job.profilers.add('%s')" % profiler.name)126        append.append("job.profilers.delete('%s')" % profiler.name)127    return prepend, append128def _sanity_check_generate_control(is_server, client_control_file):129    """130    Sanity check some of the parameters to generate_control().131    This exists as its own function so that site_control_file may call it as132    well from its own generate_control().133    @raises ValidationError if any of the parameters do not make sense.134    """135    if is_server and client_control_file:136        raise model_logic.ValidationError(137                {'tests' : 'You cannot run server tests at the same time '138                 'as directly supplying a client-side control file.'})139def generate_control(tests, is_server=False, profilers=(),140                     client_control_file='', profile_only=None,141                     test_source_build=None):142    """143    Generate a control file for a sequence of tests.144    @param tests A sequence of test control files to run.145    @param is_server bool, Is this a server control file rather than a client?146    @param profilers A list of profiler objects to enable during the tests.147    @param client_control_file Contents of a client control file to run as the148            last test after everything in tests.  Requires is_server=False.149    @param profile_only bool, should this control file run all tests in150            profile_only mode by default151    @param test_source_build: Build to be used to retrieve test code. Default152                              to None.153    @returns The control file text as a string.154    """155    _sanity_check_generate_control(is_server=is_server,156                                   client_control_file=client_control_file)157    control_file_text = EMPTY_TEMPLATE158    prepend, append = _get_profiler_commands(profilers, is_server, profile_only)159    control_file_text += _get_tests_stanza(tests, is_server, prepend, append,160                                           client_control_file,161                                           test_source_build)162    return control_file_text163def _get_test_control_files_by_build(tests, build, ignore_invalid_tests=False):164    """Get the test control files that are available for the specified build.165    @param tests A sequence of test objects to run.166    @param build: unique name by which to refer to the image.167    @param ignore_invalid_tests: flag on if unparsable tests are ignored.168    @return: A sorted list of all tests that are in the build specified.169    """170    raw_control_files = []171    # shortcut to avoid staging the image.172    if not tests:...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!!
