Пример #1
0
def pytest_configure(config):
    config._variables = {}
    paths = config.getoption('variables')
    for path in paths:
        if path == 'mysql':
            variables = mysql_json()
        else:
            ext = os.path.splitext(path)[1][1:].lower() or 'json'
            try:
                variables = import_parser(path, *parser_table[ext])
            except KeyError:
                warnings.warn(UserWarning(
                    "Could not find a parser for the file extension '{0}'. "
                    'Supported extensions are: {1}'.format(
                        ext, ', '.join(sorted(parser_table.keys())))))
                variables = import_parser(path, *parser_table['json'])
            except ValueError as e:
                raise errors.ValueError('Unable to parse {0}: {1}'.format(
                    path, e))

        if not isinstance(variables, dict):
            raise errors.ValueError('Unable to parse {0}'.format(
                path))

        reduce(_merge, [config._variables, variables])
Пример #2
0
def pytest_configure(config):
    config._variables = {}
    paths = config.getoption("variables")
    loader = config.getini("yaml_loader")
    for path in paths:
        ext = os.path.splitext(path)[1][1:].lower() or "json"
        try:
            import_type, parser_func = parser_table[ext]
            variables = import_parser(path, import_type, parser_func, loader)
        except KeyError:
            warnings.warn(
                UserWarning(
                    "Could not find a parser for the file extension '{0}'. "
                    "Supported extensions are: {1}".format(
                        ext, ", ".join(sorted(parser_table.keys()))
                    )
                )
            )
            variables = import_parser(path, *parser_table["json"])
        except ValueError as e:
            raise errors.ValueError("Unable to parse {0}: {1}".format(path, e))

        if not isinstance(variables, dict):
            raise errors.ValueError("Unable to parse {0}".format(path))

        reduce(_merge, [config._variables, variables])
Пример #3
0
def pytest_configure(config):
    config._variables = {}
    for path in config.getoption('variables'):
        ext = os.path.splitext(path)[1][1:].lower() or 'json'
        try:
            variables = import_parser(path, *parser_table[ext])
            config._variables.update(variables)
        except KeyError:
            print("Could not find a parser for the file extension '{0}'. "
                  'Supported extensions are: {1}'.format(
                      ext, ', '.join(sorted(parser_table.keys()))))
            config._variables.update(import_parser(path,
                                                   *parser_table['json']))
        except ValueError as e:
            raise errors.ValueError('Unable to parse {0}: {1}'.format(path, e))