Skip to content

Commit e890d7d

Browse files
chore: additional Python syntax modernization with Ruff unsafe fixes
Co-Authored-By: Aaron <AJ> Steers <[email protected]>
1 parent b31327c commit e890d7d

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

unit_tests/sources/declarative/interpolation/test_filters.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
def test_hash_md5_no_salt() -> None:
1616
input_string = "abcd"
17-
s = "{{ '%s' | hash('md5') }}" % input_string
17+
s = f"{{{{ '{input_string}' | hash('md5') }}}}"
1818
filter_hash = interpolation.eval(s, config={})
1919

2020
# compute expected hash calling hashlib directly
@@ -27,7 +27,7 @@ def test_hash_md5_no_salt() -> None:
2727

2828
def test_hash_md5_on_numeric_value() -> None:
2929
input_value = 123.456
30-
s = "{{ %f | hash('md5') }}" % input_value
30+
s = f"{{{{ {input_value:f} | hash('md5') }}}}"
3131
filter_hash = interpolation.eval(s, config={})
3232

3333
# compute expected hash calling hashlib directly
@@ -42,7 +42,7 @@ def test_hash_md5_with_salt() -> None:
4242
input_string = "test_input_string"
4343
input_salt = "test_input_salt"
4444

45-
s = "{{{{ '{}' | hash('md5', '{}' ) }}}}".format(input_string, input_salt)
45+
s = f"{{{{ '{input_string}' | hash('md5', '{input_salt}' ) }}}}"
4646
filter_hash = interpolation.eval(s, config={})
4747

4848
# compute expected value calling hashlib directly
@@ -58,7 +58,7 @@ def test_hash_md5_with_salt() -> None:
5858
["test_input_client_id", "some_client_secret_1", "12345", "775.78"],
5959
)
6060
def test_base64encode(input_string: str) -> None:
61-
s = "{{ '%s' | base64encode }}" % input_string
61+
s = f"{{{{ '{input_string}' | base64encode }}}}"
6262
filter_base64encode = interpolation.eval(s, config={})
6363

6464
# compute expected base64encode calling base64 library directly
@@ -76,7 +76,7 @@ def test_base64encode(input_string: str) -> None:
7676
],
7777
)
7878
def test_base64decode(input_string: str, expected_string: str) -> None:
79-
s = "{{ '%s' | base64decode }}" % input_string
79+
s = f"{{{{ '{input_string}' | base64decode }}}}"
8080
filter_base64decode = interpolation.eval(s, config={})
8181

8282
assert filter_base64decode == expected_string
@@ -112,7 +112,7 @@ def test_hmac_sha256_default() -> None:
112112
message = "test_message"
113113
secret_key = "test_secret_key"
114114

115-
s = "{{{{ '{}' | hmac('{}') }}}}".format(message, secret_key)
115+
s = f"{{{{ '{message}' | hmac('{secret_key}') }}}}"
116116
filter_hmac = interpolation.eval(s, config={})
117117

118118
# compute expected hmac using the hmac library directly
@@ -128,7 +128,7 @@ def test_hmac_sha256_explicit() -> None:
128128
message = "test_message"
129129
secret_key = "test_secret_key"
130130

131-
s = "{{{{ '{}' | hmac('{}', 'sha256') }}}}".format(message, secret_key)
131+
s = f"{{{{ '{message}' | hmac('{secret_key}', 'sha256') }}}}"
132132
filter_hmac = interpolation.eval(s, config={})
133133

134134
# compute expected hmac using the hmac library directly
@@ -160,7 +160,7 @@ def test_hmac_with_invalid_hash_type() -> None:
160160
message = "test_message"
161161
secret_key = "test_secret_key"
162162

163-
s = "{{{{ '{}' | hmac('{}', 'md5') }}}}".format(message, secret_key)
163+
s = f"{{{{ '{message}' | hmac('{secret_key}', 'md5') }}}}"
164164

165165
with pytest.raises(ValueError):
166166
interpolation.eval(s, config={})

0 commit comments

Comments
 (0)