Skip to content

Commit 1041fe9

Browse files
committed
Fixed a bug in the glob tests.
Was not properly looking in the correct relative directories.
1 parent ea45c4c commit 1041fe9

File tree

2 files changed

+22
-9
lines changed

2 files changed

+22
-9
lines changed

tests/test_config/test_utils.py

+11-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from bumpversion.config.utils import get_all_file_configs, resolve_glob_files
1111
from bumpversion.config.models import FileChange
1212
from bumpversion.config import DEFAULTS
13-
from tests.conftest import inside_dir
13+
from tests.conftest import inside_dir, get_config_data
1414

1515

1616
def write_config(tmp_path: Path, overrides: dict) -> Path:
@@ -114,6 +114,16 @@ def test_all_attributes_are_copied(self, tmp_path: Path):
114114
assert resolved_file.ignore_missing_file is True
115115
assert resolved_file.regex is True
116116

117+
def test_finds_all_files(self, fixtures_path: Path):
118+
"""Test that all files are found."""
119+
overrides = {
120+
"current_version": "1.2.3",
121+
"files": [{"glob": "glob/**/*.txt", "ignore_missing_file": True, "ignore_missing_version": True}],
122+
}
123+
with inside_dir(fixtures_path):
124+
conf, version_config, current_version = get_config_data(overrides)
125+
assert len(conf.files_to_modify) == 3
126+
117127
@pytest.mark.parametrize(
118128
["glob_exclude", "expected_number"],
119129
[

tests/test_files.py

+11-8
Original file line numberDiff line numberDiff line change
@@ -117,15 +117,15 @@ def test_dedents_properly_when_file_does_not_contain_pattern(self, fixtures_path
117117
caplog.set_level(logging.INFO)
118118
logger = get_indented_logger(__name__)
119119
logger.reset()
120-
globs = f"{fixtures_path}/glob/**/*.txt"
121120
overrides = {
122121
"current_version": "1.2.3",
123-
"files": [{"glob": str(globs), "ignore_missing_file": True, "ignore_missing_version": True}],
122+
"files": [{"glob": "glob/**/*.txt", "ignore_missing_file": True, "ignore_missing_version": True}],
124123
}
125-
conf, version_config, current_version = get_config_data(overrides)
126-
configured_file1 = files.ConfiguredFile(conf.files_to_modify[0], version_config)
127-
configured_file2 = files.ConfiguredFile(conf.files_to_modify[1], version_config)
128-
configured_file3 = files.ConfiguredFile(conf.files_to_modify[2], version_config)
124+
with inside_dir(fixtures_path):
125+
conf, version_config, current_version = get_config_data(overrides)
126+
configured_file1 = files.ConfiguredFile(conf.files_to_modify[0], version_config)
127+
configured_file2 = files.ConfiguredFile(conf.files_to_modify[1], version_config)
128+
configured_file3 = files.ConfiguredFile(conf.files_to_modify[2], version_config)
129129
new_version = current_version.bump("patch")
130130
ctx = get_context(conf)
131131

@@ -141,12 +141,15 @@ def test_dedents_properly_when_file_does_not_contain_pattern(self, fixtures_path
141141
assert logs[2] == (
142142
f"\nFile {configured_file1.file_change.filename}: replace `{{current_version}}` with `{{new_version}}`"
143143
)
144-
assert logs[3] == (
144+
assert logs[3] == " File not found, but ignoring"
145+
assert logs[4] == (
145146
f"\nFile {configured_file2.file_change.filename}: replace `{{current_version}}` with `{{new_version}}`"
146147
)
147-
assert logs[4] == (
148+
assert logs[5] == " File not found, but ignoring"
149+
assert logs[6] == (
148150
f"\nFile {configured_file3.file_change.filename}: replace `{{current_version}}` with `{{new_version}}`"
149151
)
152+
assert logs[7] == " File not found, but ignoring"
150153

151154

152155
def test_single_file_processed_twice(tmp_path: Path):

0 commit comments

Comments
 (0)