Commit cdc7aa41 by trag1c Committed by GitHub

Added downgrading note when updating to an older version (#8176)

parent 01657dde
...@@ -461,13 +461,18 @@ class Executor: ...@@ -461,13 +461,18 @@ class Executor:
) )
if isinstance(operation, Update): if isinstance(operation, Update):
initial_version = (initial_pkg := operation.initial_package).version
target_version = (target_pkg := operation.target_package).version
update_kind = (
"Updating" if target_version >= initial_version else "Downgrading"
)
return ( return (
f"<{base_tag}>Updating" f"<{base_tag}>{update_kind}"
f" <{package_color}>{operation.initial_package.name}</{package_color}> " f" <{package_color}>{initial_pkg.name}</{package_color}> "
f"(<{source_operation_color}>" f"(<{source_operation_color}>"
f"{operation.initial_package.full_pretty_version}" f"{initial_pkg.full_pretty_version}"
f"</{source_operation_color}> -> <{operation_color}>" f"</{source_operation_color}> -> <{operation_color}>"
f"{operation.target_package.full_pretty_version}</>)</>" f"{target_pkg.full_pretty_version}</>)</>"
) )
return "" return ""
......
...@@ -246,6 +246,7 @@ def test_execute_executes_a_batch_of_operations( ...@@ -246,6 +246,7 @@ def test_execute_executes_a_batch_of_operations(
Install(Package("pytest", "3.5.1")), Install(Package("pytest", "3.5.1")),
Uninstall(Package("attrs", "17.4.0")), Uninstall(Package("attrs", "17.4.0")),
Update(Package("requests", "2.18.3"), Package("requests", "2.18.4")), Update(Package("requests", "2.18.3"), Package("requests", "2.18.4")),
Update(Package("pytest", "3.5.1"), Package("pytest", "3.5.0")),
Uninstall(Package("clikit", "0.2.3")).skip("Not currently installed"), Uninstall(Package("clikit", "0.2.3")).skip("Not currently installed"),
Install(file_package), Install(file_package),
Install(directory_package), Install(directory_package),
...@@ -254,11 +255,12 @@ def test_execute_executes_a_batch_of_operations( ...@@ -254,11 +255,12 @@ def test_execute_executes_a_batch_of_operations(
) )
expected = f""" expected = f"""
Package operations: 4 installs, 1 update, 1 removal Package operations: 4 installs, 2 updates, 1 removal
• Installing pytest (3.5.1) • Installing pytest (3.5.1)
• Removing attrs (17.4.0) • Removing attrs (17.4.0)
• Updating requests (2.18.3 -> 2.18.4) • Updating requests (2.18.3 -> 2.18.4)
• Downgrading pytest (3.5.1 -> 3.5.0)
• Installing demo (0.1.0 {file_package.source_url}) • Installing demo (0.1.0 {file_package.source_url})
• Installing simple-project (1.2.3 {directory_package.source_url}) • Installing simple-project (1.2.3 {directory_package.source_url})
• Installing demo (0.1.0 master) • Installing demo (0.1.0 master)
...@@ -267,9 +269,9 @@ Package operations: 4 installs, 1 update, 1 removal ...@@ -267,9 +269,9 @@ Package operations: 4 installs, 1 update, 1 removal
expected_lines = set(expected.splitlines()) expected_lines = set(expected.splitlines())
output_lines = set(io.fetch_output().splitlines()) output_lines = set(io.fetch_output().splitlines())
assert output_lines == expected_lines assert output_lines == expected_lines
assert wheel_install.call_count == 5 assert wheel_install.call_count == 6
# Two pip uninstalls: one for the remove operation one for the update operation # 3 pip uninstalls: one for the remove operation and two for the update operations
assert len(env.executed) == 2 assert len(env.executed) == 3
assert return_code == 0 assert return_code == 0
assert prepare_spy.call_count == 2 assert prepare_spy.call_count == 2
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment