mirror of
https://github.com/ansible-collections/community.docker.git
synced 2026-07-29 11:55:04 +00:00
Python code modernization, 1/n (#1141)
* Remove unicode text prefixes. * Replace str.format() uses with f-strings. * Replace % with f-strings, and do some cleanup. * Fix wrong variable. * Avoid unnecessary string conversion.
This commit is contained in:
@@ -18,7 +18,7 @@ from ..test_support.docker_image_archive_stubbing import (
|
||||
|
||||
|
||||
def assert_no_logging(msg):
|
||||
raise AssertionError('Should not have logged anything but logged %s' % msg)
|
||||
raise AssertionError(f'Should not have logged anything but logged {msg}')
|
||||
|
||||
|
||||
def capture_logging(messages):
|
||||
@@ -41,7 +41,7 @@ def test_archived_image_action_when_missing(tar_file_name):
|
||||
fake_name = 'a:latest'
|
||||
fake_id = 'a1'
|
||||
|
||||
expected = 'Archived image %s to %s, since none present' % (fake_name, tar_file_name)
|
||||
expected = f'Archived image {fake_name} to {tar_file_name}, since none present'
|
||||
|
||||
actual = ImageManager.archived_image_action(assert_no_logging, tar_file_name, fake_name, api_image_id(fake_id))
|
||||
|
||||
@@ -65,7 +65,7 @@ def test_archived_image_action_when_invalid(tar_file_name):
|
||||
|
||||
write_irrelevant_tar(tar_file_name)
|
||||
|
||||
expected = 'Archived image %s to %s, overwriting an unreadable archive file' % (fake_name, tar_file_name)
|
||||
expected = f'Archived image {fake_name} to {tar_file_name}, overwriting an unreadable archive file'
|
||||
|
||||
actual_log = []
|
||||
actual = ImageManager.archived_image_action(
|
||||
@@ -88,9 +88,7 @@ def test_archived_image_action_when_obsolete_by_id(tar_file_name):
|
||||
|
||||
write_imitation_archive(tar_file_name, old_id, [fake_name])
|
||||
|
||||
expected = 'Archived image %s to %s, overwriting archive with image %s named %s' % (
|
||||
fake_name, tar_file_name, old_id, fake_name
|
||||
)
|
||||
expected = f'Archived image {fake_name} to {tar_file_name}, overwriting archive with image {old_id} named {fake_name}'
|
||||
actual = ImageManager.archived_image_action(assert_no_logging, tar_file_name, fake_name, api_image_id(new_id))
|
||||
|
||||
assert actual == expected
|
||||
@@ -103,11 +101,9 @@ def test_archived_image_action_when_obsolete_by_name(tar_file_name):
|
||||
|
||||
write_imitation_archive(tar_file_name, fake_id, [old_name])
|
||||
|
||||
expected = 'Archived image %s to %s, overwriting archive with image %s named %s' % (
|
||||
new_name, tar_file_name, fake_id, old_name
|
||||
)
|
||||
expected = f'Archived image {new_name} to {tar_file_name}, overwriting archive with image {fake_id} named {old_name}'
|
||||
actual = ImageManager.archived_image_action(assert_no_logging, tar_file_name, new_name, api_image_id(fake_id))
|
||||
|
||||
print('actual : %s', actual)
|
||||
print('expected : %s', expected)
|
||||
print(f'actual : {actual}')
|
||||
print(f'expected : {expected}')
|
||||
assert actual == expected
|
||||
|
||||
Reference in New Issue
Block a user