diff --git a/tests/console/commands/test_add.py b/tests/console/commands/test_add.py index 987739b234e..b51e9239a1c 100644 --- a/tests/console/commands/test_add.py +++ b/tests/console/commands/test_add.py @@ -2,11 +2,13 @@ import sys +from importlib import metadata from pathlib import Path from typing import TYPE_CHECKING import pytest +from poetry.core.semver.helpers import parse_constraint from poetry.core.semver.version import Version from poetry.repositories.legacy_repository import LegacyRepository @@ -981,7 +983,7 @@ def test_add_chooses_prerelease_if_only_prereleases_are_available( tester.execute("foo") expected = """\ -Using version ^1.2.3-beta.1 for foo +Using version ^1.2.3b1 for foo Updating dependencies Resolving dependencies... @@ -992,6 +994,10 @@ def test_add_chooses_prerelease_if_only_prereleases_are_available( • Installing foo (1.2.3b1) """ + if not parse_constraint(">1.1.0a7").allows( + Version.parse(metadata.version("poetry-core")) + ): + expected = expected.replace("^1.2.3b1", "^1.2.3-beta.1") assert expected in tester.io.fetch_output() @@ -1912,7 +1918,7 @@ def test_add_chooses_prerelease_if_only_prereleases_are_available_old_installer( old_tester.execute("foo") expected = """\ -Using version ^1.2.3-beta.1 for foo +Using version ^1.2.3b1 for foo Updating dependencies Resolving dependencies... @@ -1923,6 +1929,10 @@ def test_add_chooses_prerelease_if_only_prereleases_are_available_old_installer( - Installing foo (1.2.3b1) """ + if not parse_constraint(">1.1.0a7").allows( + Version.parse(metadata.version("poetry-core")) + ): + expected = expected.replace("^1.2.3b1", "^1.2.3-beta.1") assert expected in old_tester.io.fetch_output() diff --git a/tests/console/commands/test_version.py b/tests/console/commands/test_version.py index b73c92a4fc5..9f597a043f1 100644 --- a/tests/console/commands/test_version.py +++ b/tests/console/commands/test_version.py @@ -1,9 +1,13 @@ from __future__ import annotations +from importlib import metadata from typing import TYPE_CHECKING import pytest +from poetry.core.semver.helpers import parse_constraint +from poetry.core.semver.version import Version + from poetry.console.commands.version import VersionCommand @@ -35,23 +39,27 @@ def tester(command_tester_factory: CommandTesterFactory) -> CommandTester: ("1.2.3", "patch", "1.2.4"), ("1.2.3", "minor", "1.3.0"), ("1.2.3", "major", "2.0.0"), - ("1.2.3", "prepatch", "1.2.4-alpha.0"), - ("1.2.3", "preminor", "1.3.0-alpha.0"), - ("1.2.3", "premajor", "2.0.0-alpha.0"), + ("1.2.3", "prepatch", "1.2.4a0"), + ("1.2.3", "preminor", "1.3.0a0"), + ("1.2.3", "premajor", "2.0.0a0"), ("1.2.3-beta.1", "patch", "1.2.3"), ("1.2.3-beta.1", "minor", "1.3.0"), ("1.2.3-beta.1", "major", "2.0.0"), - ("1.2.3-beta.1", "prerelease", "1.2.3-beta.2"), - ("1.2.3-beta1", "prerelease", "1.2.3-beta.2"), - ("1.2.3beta1", "prerelease", "1.2.3-beta.2"), - ("1.2.3b1", "prerelease", "1.2.3-beta.2"), - ("1.2.3", "prerelease", "1.2.4-alpha.0"), + ("1.2.3-beta.1", "prerelease", "1.2.3b2"), + ("1.2.3-beta1", "prerelease", "1.2.3b2"), + ("1.2.3beta1", "prerelease", "1.2.3b2"), + ("1.2.3b1", "prerelease", "1.2.3b2"), + ("1.2.3", "prerelease", "1.2.4a0"), ("0.0.0", "1.2.3", "1.2.3"), ], ) def test_increment_version( version: str, rule: str, expected: str, command: VersionCommand ): + if not parse_constraint(">1.1.0a7").allows( + Version.parse(metadata.version("poetry-core")) + ): + expected = expected.replace("a", "-alpha.").replace("b", "-beta.") assert command.increment_version(version, rule).text == expected