Skip to content
Snippets Groups Projects
Commit b8bf6d51 authored by Moul's avatar Moul
Browse files

[mod] #194: tests: Use f-string

parent 5214297b
No related branches found
No related tags found
1 merge request!195#194, #376: Use f-string and sys.exit()
Pipeline #13768 passed
......@@ -21,7 +21,7 @@ from silkaj.cli import cli
pubkey = "3rp7ahDGeXqffBQTnENiXEFXYS7BRjYmS33NbgfCuDc8"
checksum = "DFQ"
pubkey_checksum = pubkey + ":" + checksum
pubkey_checksum = f"{pubkey}:{checksum}"
pubkey_seedhex_authfile = (
"3bc6f2484e441e40562155235cdbd8ce04c25e7df35bf5f87c067bf239db8511"
)
......@@ -31,7 +31,7 @@ pubkey_seedhex_authfile = (
"command, excepted_output",
[
(["checksum", pubkey_checksum], "The checksum is valid"),
(["checksum", pubkey + ":vAK"], "The checksum is invalid"),
(["checksum", f"{pubkey}:vAK"], "The checksum is invalid"),
(["checksum", pubkey], pubkey_checksum),
(["checksum", "uid"], "Error: Wrong public key format"),
(["checksum"], MESSAGE),
......@@ -44,4 +44,4 @@ def test_checksum_command(command, excepted_output):
with open("authfile", "w") as f:
f.write(pubkey_seedhex_authfile)
result = CliRunner().invoke(cli, args=command)
assert result.output == excepted_output + "\n"
assert result.output == f"{excepted_output}\n"
......@@ -42,7 +42,7 @@ def test_gen_checksum(pubkey, checksum):
],
)
def test_validate_checksum(pubkey, checksum, expected, capsys):
pubkey_with_ck = str(pubkey + ":" + checksum)
pubkey_with_ck = f"{pubkey}:{checksum}"
if expected == None:
assert pubkey == crypto_tools.validate_checksum(pubkey_with_ck)
else:
......
......@@ -30,14 +30,8 @@ def test_display_amount(message, amount, currency_symbol):
amount_UD = round(amount / mock_ud_value, 2)
expected = [
[
message + " (unit|relative)",
str(amount / 100)
+ " "
+ currency_symbol
+ " | "
+ str(amount_UD)
+ " UD "
+ currency_symbol,
f"{message} (unit|relative)",
f"{str(amount / 100)} {currency_symbol} | {str(amount_UD)} UD {currency_symbol}",
]
]
tx = list()
......@@ -56,9 +50,9 @@ def test_display_amount(message, amount, currency_symbol):
def test_display_pubkey(message, pubkey, id, monkeypatch):
monkeypatch.setattr(wot_tools, "is_member", patched_is_member)
expected = [[message + " (pubkey:checksum)", display_pubkey_and_checksum(pubkey)]]
expected = [[f"{message} (pubkey:checksum)", display_pubkey_and_checksum(pubkey)]]
if id:
expected.append([message + " (id)", id])
expected.append([f"{message} (id)", id])
tx = list()
display_pubkey(tx, message, pubkey)
assert tx == expected
......
......@@ -55,8 +55,8 @@ def test_check_passed_blocks_range(from_block, to_block, capsys, monkeypatch):
assert pytest_wrapped_e.value.code == FAILURE_EXIT_STATUS
captured = capsys.readouterr()
if to_block == HEAD_BLOCK + 1:
expected = "Passed TO_BLOCK argument is bigger than the head block: " + str(
HEAD_BLOCK
expected = (
f"Passed TO_BLOCK argument is bigger than the head block: {str(HEAD_BLOCK)}"
)
else:
expected = "TO_BLOCK should be bigger or equal to FROM_BLOCK\n"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment