Best Python code snippet using behave
__main__.py
Source:__main__.py  
...50    if config.tags_help:51        print(TAG_HELP)52        return 053    if config.lang_list:54        print_language_list()55        return 056    if config.lang_help:57        print_language_help(config)58        return 059    if not config.format:60        config.format = [config.default_format]61    elif config.format and "format" in config.defaults:62        # -- CASE: Formatter are specified in behave configuration file.63        #    Check if formatter are provided on command-line, too.64        if len(config.format) == len(config.defaults["format"]):65            # -- NO FORMATTER on command-line: Add default formatter.66            config.format.append(config.default_format)67    if "help" in config.format:68        print_formatters("Available formatters:")69        return 070    if len(config.outputs) > len(config.format):71        print("CONFIG-ERROR: More outfiles (%d) than formatters (%d)." % \72              (len(config.outputs), len(config.format)))73        return 174    # -- MAIN PART:75    failed = True76    try:77        reset_runtime()78        runner = runner_class(config)79        failed = runner.run()80    except ParserError as e:81        print(u"ParserError: %s" % e)82    except ConfigError as e:83        print(u"ConfigError: %s" % e)84    except FileNotFoundError as e:85        print(u"FileNotFoundError: %s" % e)86    except InvalidFileLocationError as e:87        print(u"InvalidFileLocationError: %s" % e)88    except InvalidFilenameError as e:89        print(u"InvalidFilenameError: %s" % e)90    except ConstraintError as e:91        print(u"ConstraintError: %s" % e)92    except Exception as e:93        # -- DIAGNOSTICS:94        text = _text(e)95        print(u"Exception %s: %s" % (e.__class__.__name__, text))96        raise97    if config.show_snippets and runner.undefined_steps:98        print_undefined_step_snippets(runner.undefined_steps,99                                      colored=config.color)100    return_code = 0101    if failed:102        return_code = 1103    return return_code104# ---------------------------------------------------------------------------105# MAIN SUPPORT FOR: run_behave()106# ---------------------------------------------------------------------------107def print_language_list(stream=None):108    """Print list of supported languages, like:109    * English110    * French111    * German112    * ...113    """114    from behave.i18n import languages115    if stream is None:116        stream = sys.stdout117        if six.PY2:118            # -- PYTHON2: Overcome implicit encode problems (encoding=ASCII).119            stream = codecs.getwriter("UTF-8")(sys.stdout)120    iso_codes = languages.keys()121    print("Languages available:")...azure.py
Source:azure.py  
...51        }52        cmds.register_command("translatify-list", self.print_language_list)53        cmds.register_command("translatify", self.translatify, varargs=True)54        cmds.register_command("translatify-native", self.translatify_native, varargs=True)55    def print_language_list(self):56        """57        Returns a readable list of languages supported by Azure for translation.58        """59        message = ""60        req = requests.get(self.config.language_list_url)61        text = req.json()62        for key, entry in text.get("translation").items():63            message += f"{key} - {entry.get('name')} | "64        # Format string65        message = message.rstrip(" | ")66        return message67    def get_translation_from_azure(self, language, text):68        """69        Takes a target language and string,...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!!
