def test_error_bad_path(): with util.Project(project="b") as project: ctx = config.init_project_ctx(project.dir) cfg = config.parse(ctx) assert cfg (project.dir / "setup.py").unlink() try: list(rewrite.iter_path_patterns_items(cfg.file_patterns)) assert False, "expected IOError" except IOError as ex: assert "setup.py" in str(ex)
def test_iter_file_paths(): with util.Project(project="a") as project: ctx = config.init_project_ctx(project.dir) assert ctx cfg = config.parse(ctx) assert cfg _paths_and_patterns = rewrite.iter_path_patterns_items( cfg.file_patterns) file_paths = { str(file_path) for file_path, patterns in _paths_and_patterns } assert file_paths == {"bumpver.toml", "README.md"}
def test_iter_file_globs(): with util.Project(project="b") as project: ctx = config.init_project_ctx(project.dir) cfg = config.parse(ctx) assert cfg _paths_and_patterns = rewrite.iter_path_patterns_items( cfg.file_patterns) file_paths = { str(file_path) for file_path, patterns in _paths_and_patterns } assert file_paths == { "setup.cfg", "setup.py", "README.rst", "src/module_v1/__init__.py", "src/module_v2/__init__.py", }
def test_v1_error_bad_pattern(): with util.Project(project="b") as project: ctx = config.init_project_ctx(project.dir) cfg = config.parse(ctx) assert cfg patterns = copy.deepcopy(cfg.file_patterns) original_pattern = patterns["setup.py"][0] invalid_pattern = v1patterns.compile_pattern( original_pattern.version_pattern, original_pattern.raw_pattern + ".invalid", ) patterns["setup.py"] = [invalid_pattern] try: old_vinfo = v1version.parse_version_info("v201808.0233") new_vinfo = v1version.parse_version_info("v201809.1234") list(v1rewrite.diff(old_vinfo, new_vinfo, patterns)) assert False, "expected rewrite.NoPatternMatch" except rewrite.NoPatternMatch as ex: assert "setup.py" in str(ex)