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:
@@ -14,15 +14,15 @@ from ansible_collections.community.docker.plugins.module_utils._scramble import
|
||||
|
||||
|
||||
@pytest.mark.parametrize('plaintext, key, scrambled', [
|
||||
(u'', b'0', '=S='),
|
||||
(u'hello', b'\x00', '=S=aGVsbG8='),
|
||||
(u'hello', b'\x01', '=S=aWRtbW4='),
|
||||
('', b'0', '=S='),
|
||||
('hello', b'\x00', '=S=aGVsbG8='),
|
||||
('hello', b'\x01', '=S=aWRtbW4='),
|
||||
])
|
||||
def test_scramble_unscramble(plaintext, key, scrambled):
|
||||
scrambled_ = scramble(plaintext, key)
|
||||
print('{0!r} == {1!r}'.format(scrambled_, scrambled))
|
||||
print(f'{scrambled_!r} == {scrambled!r}')
|
||||
assert scrambled_ == scrambled
|
||||
|
||||
plaintext_ = unscramble(scrambled, key)
|
||||
print('{0!r} == {1!r}'.format(plaintext_, plaintext))
|
||||
print(f'{plaintext_!r} == {plaintext!r}')
|
||||
assert plaintext_ == plaintext
|
||||
|
||||
Reference in New Issue
Block a user