def test_path_from_config_do_not_depend_on_cwd( monkeypatch: MonkeyPatch, ) -> None: # Issue 572 config1 = cli.load_config("test/fixtures/config-with-relative-path.yml") monkeypatch.chdir('test') config2 = cli.load_config("fixtures/config-with-relative-path.yml") assert config1['exclude_paths'].sort() == config2['exclude_paths'].sort()
def test_ensure_config_are_equal(base_arguments, args, config): command = base_arguments + args cli_parser = cli.get_cli_parser() _real_pathlib_resolve = Path.resolve def _fake_pathlib_resolve(self): try: return _real_pathlib_resolve(self) except FileNotFoundError: if self != Path(args[-1]): raise return Path.cwd() / self options = cli_parser.parse_args(command) file_config = cli.load_config(config) for key, val in file_config.items(): # config_file does not make sense in file_config if key == 'config_file': continue if key in {'exclude_paths', 'rulesdir'}: val = [Path(p) for p in val] assert val == getattr(options, key)
def test_ensure_config_are_equal(base_arguments, args, config, monkeypatch): command = base_arguments + args cli_parser = cli.get_cli_parser() _real_pathlib_resolve = Path.resolve def _fake_pathlib_resolve(self): try: return _real_pathlib_resolve(self) except FileNotFoundError: if self != Path(args[-1]): raise return Path.cwd() / self with monkeypatch.context() as mp_ctx: if ( sys.version_info[:2] < (3, 6) and args[-2:] == ["-r", "test/fixtures/rules/"] ): mp_ctx.setattr(Path, 'resolve', _fake_pathlib_resolve) options = cli_parser.parse_args(command) file_config = cli.load_config(config) for key, val in file_config.items(): if key in {'exclude_paths', 'rulesdir'}: val = [Path(p) for p in val] assert val == getattr(options, key)
def test_ensure_config_are_equal(base_arguments, args, config): command = base_arguments + args options, _ = cli.get_cli_parser().parse_args(command) file_config = cli.load_config(config) for key in file_config.keys(): assert file_config[key] == getattr(options, key)
def test_ensure_config_are_equal(base_arguments: List[str], args: List[str], config: str) -> None: command = base_arguments + args cli_parser = cli.get_cli_parser() options = cli_parser.parse_args(command) file_config = cli.load_config(config) for key, val in file_config.items(): # config_file does not make sense in file_config if key == 'config_file': continue if key in {'exclude_paths', 'rulesdir'}: val = [Path(p) for p in val] assert val == getattr(options, key)