How to use get_symbol_module_path_from_statement method in avocado

Best Python code snippet using avocado_python

imported.py

Source:imported.py Github

copy

Full Screen

...131 relative_level = getattr(statement, "level", 0) or 0132 return "".join(["." for _ in range(relative_level)])133 @staticmethod134 def get_symbol_from_statement(statement):135 return ImportedSymbol.get_symbol_module_path_from_statement(statement)[0]136 @staticmethod137 def get_module_path_from_statement(statement):138 return ImportedSymbol.get_symbol_module_path_from_statement(statement)[1]139 @staticmethod140 def get_symbol_module_path_from_statement(statement, name_index=0):141 symbol = ""142 module_path = ""143 module_alias = ""144 symbol_alias = ""145 import_as = get_statement_import_as(statement)146 names = list(import_as.keys())147 as_names = list(import_as.values())148 if isinstance(statement, ast.Import):149 # On an Import statement, it's impossible to import a symbol150 # so everything is the module_path151 module_path = names[name_index]152 module_alias = as_names[name_index]153 elif isinstance(statement, ast.ImportFrom):154 symbol = names[name_index]155 relative = ImportedSymbol._get_relative_prefix(statement)156 module_name = statement.module or ""157 module_path = relative + module_name158 symbol_alias = as_names[name_index]159 return symbol, module_path, module_alias, symbol_alias160 @property161 def module_name(self):162 """The final name of the module from its importer perspective.163 If a alias exists, it will be the alias name. If not, it will164 be the original name.165 """166 if self.module_alias:167 return self.module_alias168 return self.module_path169 @property170 def symbol_name(self):171 """The final name of the symbol from its importer perspective.172 If a alias exists, it will be the alias name. If not, it will173 be the original name.174 """175 if self.symbol_alias:176 return self.symbol_alias177 return self.symbol178 @classmethod179 def from_statement(cls, statement, importer_fs_path=None, index=0):180 (181 symbol,182 module_path,183 module_alias,184 symbol_alias,185 ) = cls.get_symbol_module_path_from_statement(statement, index)186 return cls(module_path, symbol, importer_fs_path, module_alias, symbol_alias)187 def to_str(self):188 """Returns a string representation of the plausible statement used."""189 if not self.symbol:190 return f"import {self.module_path}"191 return f"from {self.module_path} import {self.symbol}"192 def is_relative(self):193 """Returns whether the imported symbol is on a relative path."""194 return self.module_path.startswith(".")195 def get_relative_module_fs_path(self):196 """Returns the module base dir, based on its relative path197 The base dir for the module is the directory where one is198 expected to find the first module of the module path. For a199 module path of "..foo.bar", and its importer being at...

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 avocado 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