Skip to content

Commit

Permalink
Merge pull request #8468 from pfmoore/nr_test_messages
Browse files Browse the repository at this point in the history
Test message check fixes
  • Loading branch information
pfmoore authored Jun 19, 2020
2 parents edda927 + a7e3f8d commit 3a3d1d5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
7 changes: 4 additions & 3 deletions tests/functional/test_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -1744,16 +1744,17 @@ def test_user_config_accepted(script):
@pytest.mark.parametrize(
'install_args, expected_message', [
([], 'Requirement already satisfied: pip'),
(['--upgrade'], 'Requirement already up-to-date: pip in'),
(['--upgrade'], 'Requirement already {}: pip in'),
]
)
@pytest.mark.parametrize("use_module", [True, False])
@pytest.mark.fails_on_new_resolver
def test_install_pip_does_not_modify_pip_when_satisfied(
script, install_args, expected_message, use_module):
script, install_args, expected_message, use_module, use_new_resolver):
"""
Test it doesn't upgrade the pip if it already satisfies the requirement.
"""
variation = "satisfied" if use_new_resolver else "up-to-date"
expected_message = expected_message.format(variation)
result = script.pip_install_local(
'pip', *install_args, use_module=use_module
)
Expand Down
22 changes: 15 additions & 7 deletions tests/functional/test_install_upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@ def test_invalid_upgrade_strategy_causes_error(script):
assert "invalid choice" in result.stderr


@pytest.mark.fails_on_new_resolver
def test_only_if_needed_does_not_upgrade_deps_when_satisfied(script):
def test_only_if_needed_does_not_upgrade_deps_when_satisfied(
script,
use_new_resolver
):
"""
It doesn't upgrade a dependency if it already satisfies the requirements.
Expand All @@ -57,9 +59,12 @@ def test_only_if_needed_does_not_upgrade_deps_when_satisfied(script):
.format(**globals()))
not in result.files_deleted
), "should not have uninstalled simple==2.0"

msg = "Requirement already satisfied"
if not use_new_resolver:
msg = msg + ", skipping upgrade: simple"
assert (
"Requirement already satisfied, skipping upgrade: simple"
in result.stdout
msg in result.stdout
), "did not print correct message for not-upgraded requirement"


Expand Down Expand Up @@ -178,8 +183,7 @@ def test_upgrade_if_requested(script):
)


@pytest.mark.fails_on_new_resolver
def test_upgrade_with_newest_already_installed(script, data):
def test_upgrade_with_newest_already_installed(script, data, use_new_resolver):
"""
If the newest version of a package is already installed, the package should
not be reinstalled and the user should be informed.
Expand All @@ -189,7 +193,11 @@ def test_upgrade_with_newest_already_installed(script, data):
'install', '--upgrade', '-f', data.find_links, '--no-index', 'simple'
)
assert not result.files_created, 'simple upgraded when it should not have'
assert 'already up-to-date' in result.stdout, result.stdout
if use_new_resolver:
msg = "Requirement already satisfied"
else:
msg = "already up-to-date"
assert msg in result.stdout, result.stdout


@pytest.mark.network
Expand Down

0 comments on commit 3a3d1d5

Please sign in to comment.