def parse(lintdir): parser = Parser() def _parse(name): path = os.path.join(lintdir, name) return parser(path) return _parse
def config(request): """Finds, loads and returns the config for the linter name specified by the LINTER global variable in the calling module. This implies that each test file (that uses this fixture) should only be used to test a single linter. If no LINTER variable is defined, the test will fail. """ if not hasattr(request.module, 'LINTER'): pytest.fail( "'config' fixture used from a module that didn't set the LINTER variable" ) name = request.module.LINTER config_path = os.path.join(lintdir, '{}.yml'.format(name)) parser = Parser(build.topsrcdir) # TODO Don't assume one linter per yaml file return parser.parse(config_path)[0]
def __init__(self, *args, **kwargs): TestCase.__init__(self, *args, **kwargs) self._lintdir = os.path.join(here, 'linters') self._parse = Parser()