get function from functions_mapping, if not found, then try to check if builtin function. Args: function_name (str): function name functions_mapping (dict): functions mapping Returns: mapping function object. Raises: exceptions.FunctionNotFound:
(
function_name: Text, functions_mapping: FunctionsMapping
)
| 244 | |
| 245 | |
| 246 | def get_mapping_function( |
| 247 | function_name: Text, functions_mapping: FunctionsMapping |
| 248 | ) -> Callable: |
| 249 | """get function from functions_mapping, |
| 250 | if not found, then try to check if builtin function. |
| 251 | |
| 252 | Args: |
| 253 | function_name (str): function name |
| 254 | functions_mapping (dict): functions mapping |
| 255 | |
| 256 | Returns: |
| 257 | mapping function object. |
| 258 | |
| 259 | Raises: |
| 260 | exceptions.FunctionNotFound: function is neither defined in debugtalk.py nor builtin. |
| 261 | |
| 262 | """ |
| 263 | if function_name in functions_mapping: |
| 264 | return functions_mapping[function_name] |
| 265 | |
| 266 | elif function_name in ["parameterize", "P"]: |
| 267 | return loader.load_csv_file |
| 268 | |
| 269 | elif function_name in ["environ", "ENV"]: |
| 270 | return utils.get_os_environ |
| 271 | |
| 272 | elif function_name in ["multipart_encoder", "multipart_content_type"]: |
| 273 | # extension for upload test |
| 274 | from httprunner.ext import uploader |
| 275 | |
| 276 | return getattr(uploader, function_name) |
| 277 | |
| 278 | try: |
| 279 | # check if HttpRunner builtin functions |
| 280 | built_in_functions = loader.load_builtin_functions() |
| 281 | return built_in_functions[function_name] |
| 282 | except KeyError: |
| 283 | pass |
| 284 | |
| 285 | try: |
| 286 | # check if Python builtin functions |
| 287 | return getattr(builtins, function_name) |
| 288 | except AttributeError: |
| 289 | pass |
| 290 | |
| 291 | raise exceptions.FunctionNotFound(f"{function_name} is not found.") |
| 292 | |
| 293 | |
| 294 | def parse_string( |
no outgoing calls
no test coverage detected