Skip to content

Commit

Permalink
Fixed some tests !minor
Browse files Browse the repository at this point in the history
  • Loading branch information
coordt committed Jan 27, 2024
1 parent 5d9bab0 commit 8bfa5d9
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 1 deletion.
Empty file removed tests/test_cli.py
Empty file.
2 changes: 1 addition & 1 deletion tests/test_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ def test_update_file_does_not_modify_non_toml_files(self, tmp_path: Path) -> Non

overrides = {"current_version": "1.2.3", "files": [{"filename": str(version_path)}]}
conf, version_config, current_version = get_config_data(overrides)
new_version = current_version.bump("patch", version_config.order)
new_version = current_version.bump("patch")
datafile_config = FileChange(
filename=str(version_path),
key_path="",
Expand Down
52 changes: 52 additions & 0 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
"""Tests for the utils module."""
from itertools import combinations

import pytest
from bumpversion import utils

Expand Down Expand Up @@ -78,3 +80,53 @@ def test_non_dict_element_raises_valueerror(self):
# Act/Assert
with pytest.raises(ValueError):
utils.set_nested_value(d, value, path)


def pytest_generate_tests(metafunc):
if "flag_permutation" in metafunc.fixturenames:
flags = [
"a",
"i",
"L",
"m",
"s",
"u",
"x",
]
permutes = flags[:]
permutes.extend(["".join(p) for p in combinations(flags, 2)])
permutes.extend(["".join(p) for p in combinations(flags, 3)])
permutes.extend(["".join(p) for p in combinations(flags, 4)])
permutes.extend(["".join(p) for p in combinations(flags, 5)])
permutes.extend(["".join(p) for p in combinations(flags, 6)])
permutes.extend(["".join(p) for p in combinations(flags, 7)])
metafunc.parametrize(
"flag_permutation",
permutes,
)


class TestExtractRegexFlags:
def test_returns_flags_when_available(self, flag_permutation):
"""It should return the flags when available."""
# Arrange
regex = f"(?{flag_permutation})abc"
expected = ("abc", f"(?{flag_permutation})")

# Act
actual_flags = utils.extract_regex_flags(regex)

# Assert
assert actual_flags == expected

def test_returns_empty_string_when_no_flags(self):
"""It should return an empty string when no flags are present."""
# Arrange
regex = "abc"
expected = ("abc", "")

# Act
actual_flags = utils.extract_regex_flags(regex)

# Assert
assert actual_flags == expected

0 comments on commit 8bfa5d9

Please sign in to comment.