Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Increase coverage #268

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 12, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions test_semver.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
parse_version_info,
process,
replace,
cmd_nextver,
)

SEMVERFUNCS = [
Expand Down Expand Up @@ -659,6 +660,8 @@ def test_should_not_allow_to_compare_version_with_int():
v1 > 1
with pytest.raises(TypeError):
1 > v1
with pytest.raises(TypeError):
v1.compare(1)


def test_should_compare_prerelease_with_numbers_and_letters():
Expand Down Expand Up @@ -911,6 +914,22 @@ def test_should_parse_cli_arguments(cli, expected):
# check subcommand
(cmd_check, Namespace(version="1.2.3"), does_not_raise(None)),
(cmd_check, Namespace(version="1.2"), pytest.raises(ValueError)),
# nextver subcommand
(
cmd_nextver,
Namespace(version="1.2.3", part="major"),
does_not_raise("2.0.0"),
),
(
cmd_nextver,
Namespace(version="1.2", part="major"),
pytest.raises(ValueError),
),
(
cmd_nextver,
Namespace(version="1.2.3", part="nope"),
pytest.raises(ValueError),
),
],
)
def test_should_process_parsed_cli_arguments(func, args, expectation):
Expand Down Expand Up @@ -1074,3 +1093,36 @@ def test_next_version_with_versioninfo(version, part, expected):
next_version = ver.next_version(part)
assert isinstance(next_version, VersionInfo)
assert str(next_version) == expected


@pytest.mark.parametrize(
"version, expected",
[
(
VersionInfo(major=1, minor=2, patch=3, prerelease=None, build=None),
"VersionInfo(major=1, minor=2, patch=3, prerelease=None, build=None)",
),
(
VersionInfo(major=1, minor=2, patch=3, prerelease="r.1", build=None),
"VersionInfo(major=1, minor=2, patch=3, prerelease='r.1', build=None)",
),
(
VersionInfo(major=1, minor=2, patch=3, prerelease="dev.1", build=None),
"VersionInfo(major=1, minor=2, patch=3, prerelease='dev.1', build=None)",
),
(
VersionInfo(major=1, minor=2, patch=3, prerelease="dev.1", build="b.1"),
"VersionInfo(major=1, minor=2, patch=3, prerelease='dev.1', build='b.1')",
),
(
VersionInfo(major=1, minor=2, patch=3, prerelease="r.1", build="b.1"),
"VersionInfo(major=1, minor=2, patch=3, prerelease='r.1', build='b.1')",
),
(
VersionInfo(major=1, minor=2, patch=3, prerelease="r.1", build="build.1"),
"VersionInfo(major=1, minor=2, patch=3, prerelease='r.1', build='build.1')",
),
],
)
def test_repr(version, expected):
assert repr(version) == expected