Skip to content

Commit 58da6ce

Browse files
committed
Cleanups identified by transition to Ruff.
1 parent c5c0fba commit 58da6ce

File tree

5 files changed

+22
-22
lines changed

5 files changed

+22
-22
lines changed

pth-tester/pth_tester.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
has_socket = False
33

44

5-
# The pth_tester module should be initalized by processing the `.pth` file
5+
# The pth_tester module should be initialized by processing the `.pth` file
66
# created on installation.
77
def init():
88
global initialized

tests/test_common.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ def test_bootstrap_modules():
5151
except ModuleNotFoundError:
5252
missing.append(module)
5353

54-
assert (
55-
len(missing) == 0
56-
), f"Missing bootstrap modules: {', '.join(str(m) for m in missing)}"
54+
assert len(missing) == 0, (
55+
f"Missing bootstrap modules: {', '.join(str(m) for m in missing)}"
56+
)
5757

5858

5959
def test_stdlib_modules():
@@ -139,9 +139,9 @@ def test_stdlib_modules():
139139
except ModuleNotFoundError:
140140
missing.append(module)
141141

142-
assert (
143-
len(missing) == 0
144-
), f"Missing stdlib modules: {', '.join(str(m) for m in missing)}"
142+
assert len(missing) == 0, (
143+
f"Missing stdlib modules: {', '.join(str(m) for m in missing)}"
144+
)
145145

146146

147147
def test_sysconfig_data():
@@ -284,9 +284,9 @@ def test_hashlib():
284284
digest_args = []
285285
msg = getattr(hashlib, algorithm)()
286286
msg.update(b"Hello world")
287-
assert (
288-
msg.hexdigest(*digest_args) == expected
289-
), f"{algorithm} digest was {msg.hexdigest(*digest_args)}"
287+
assert msg.hexdigest(*digest_args) == expected, (
288+
f"{algorithm} digest was {msg.hexdigest(*digest_args)}"
289+
)
290290

291291

292292
def test_sqlite3():

tests/test_macOS.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,6 @@ def test_stdlib_modules():
8181
except ModuleNotFoundError:
8282
missing.append(module)
8383

84-
assert (
85-
len(missing) == 0
86-
), f"Missing stdlib modules: {', '.join(str(m) for m in missing)}"
84+
assert len(missing) == 0, (
85+
f"Missing stdlib modules: {', '.join(str(m) for m in missing)}"
86+
)

tests/test_thirdparty.py

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

1212
def xfail_if_not_installed(package_name):
1313
"""A test decorator that xfails a test if the named package isn't installed.
14-
The third-party tests are dependant on packages being built. During pre-release some
14+
The third-party tests are dependent on packages being built. During pre-release some
1515
packages won't be compilable. So - the pyproject.toml installs third party packages
1616
with some conditional gating.
1717
@@ -114,7 +114,7 @@ def test_cryptography():
114114

115115
cert = x509.load_pem_x509_certificate(cert_pem, default_backend())
116116
domain = cert.subject.get_attributes_for_oid(NameOID.COMMON_NAME)[0].value
117-
assert "www.android.com" == domain
117+
assert domain == "www.android.com"
118118

119119

120120
@xfail_if_not_installed("pyspamsum")
@@ -176,7 +176,7 @@ def test_numpy():
176176
from numpy import array
177177

178178
# Numpy is the thousand pound gorilla packaging test.
179-
assert [4, 7] == (array([1, 2]) + array([3, 5])).tolist()
179+
assert (array([1, 2]) + array([3, 5])).tolist() == [4, 7]
180180

181181

182182
@xfail_if_not_installed("pandas")
@@ -191,10 +191,10 @@ def test_pandas():
191191

192192
# Pandas 1.5 changed the API for to_csv()
193193
if tuple(int(v) for v in __version__.split(".")[:2]) < (1, 5):
194-
kwargs = dict(line_terminator="\n")
194+
kwargs = {"line_terminator": "\n"}
195195
else:
196-
kwargs = dict(lineterminator="\n")
196+
kwargs = {"lineterminator": "\n"}
197197

198-
assert (
199-
",Letter,Number\n" "0,alpha,1\n" "1,bravo,2\n" "2,charlie,3\n"
200-
) == df.to_csv(**kwargs)
198+
assert df.to_csv(**kwargs) == (
199+
",Letter,Number\n0,alpha,1\n1,bravo,2\n2,charlie,3\n"
200+
)

tests/testbed.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def run_tests():
3232
# macOS, output the log sentinel multiple times to decrease the chance of
3333
# this happening.
3434
if sys.platform in {"darwin", "ios"}:
35-
for i in range(0, 6):
35+
for _ in range(0, 6):
3636
time.sleep(0.5)
3737
print(f">>>>>>>>>> EXIT {returncode} <<<<<<<<<<")
3838
else:

0 commit comments

Comments
 (0)