Skip to content

Commit ce6e369

Browse files
woodruffwsigmavirus24
authored andcommitted
tests: reformat with black
Signed-off-by: William Woodruff <william@astral.sh>
1 parent 985b962 commit ce6e369

File tree

4 files changed

+28
-56
lines changed

4 files changed

+28
-56
lines changed

tests/test_register.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,12 @@
1111
@pytest.fixture()
1212
def register_settings(make_settings):
1313
"""Return a factory function for settings.Settings for register."""
14-
return make_settings(
15-
"""
14+
return make_settings("""
1615
[pypi]
1716
repository: https://test.pypi.org/legacy/
1817
username:foo
1918
password:bar
20-
"""
21-
)
19+
""")
2220

2321

2422
def test_successful_register(register_settings):
@@ -105,8 +103,7 @@ def none_register(*args, **settings_kwargs):
105103

106104
def test_values_from_env_not_pypi(monkeypatch, write_config_file):
107105
"""Use env vars for settings when run from command line."""
108-
write_config_file(
109-
"""
106+
write_config_file("""
110107
[distutils]
111108
index-servers =
112109
notpypi
@@ -115,8 +112,7 @@ def test_values_from_env_not_pypi(monkeypatch, write_config_file):
115112
repository: https://upload.example.org/legacy/
116113
username:someusername
117114
password:password
118-
"""
119-
)
115+
""")
120116

121117
def none_register(*args, **settings_kwargs):
122118
pass

tests/test_settings.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,12 @@ def test_settings_transforms_repository_config_pypi(write_config_file):
3434
3535
Ignores the username setting due to PyPI being the index.
3636
"""
37-
config_file = write_config_file(
38-
"""
37+
config_file = write_config_file("""
3938
[pypi]
4039
repository: https://upload.pypi.org/legacy/
4140
username:this-is-ignored
4241
password:password
43-
"""
44-
)
42+
""")
4543

4644
s = settings.Settings(config_file=config_file)
4745
assert s.repository_config["repository"] == "https://upload.pypi.org/legacy/"
@@ -57,8 +55,7 @@ def test_settings_transforms_repository_config_pypi(write_config_file):
5755

5856
def test_settings_transforms_repository_config_non_pypi(write_config_file):
5957
"""Set repository config and defaults when .pypirc is provided."""
60-
config_file = write_config_file(
61-
"""
58+
config_file = write_config_file("""
6259
[distutils]
6360
index-servers =
6461
notpypi
@@ -67,8 +64,7 @@ def test_settings_transforms_repository_config_non_pypi(write_config_file):
6764
repository: https://upload.example.org/legacy/
6865
username:someusername
6966
password:password
70-
"""
71-
)
67+
""")
7268

7369
s = settings.Settings(config_file=config_file, repository_name="notpypi")
7470
assert s.repository_config["repository"] == "https://upload.example.org/legacy/"

tests/test_upload.py

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -199,14 +199,12 @@ def test_warns_potential_pgp_removal_on_3p_index(
199199
make_settings, stub_repository, caplog
200200
):
201201
"""Warn when a PGP signature is specified for upload to a third-party index."""
202-
upload_settings = make_settings(
203-
"""
202+
upload_settings = make_settings("""
204203
[pypi]
205204
repository: https://example.com/not-a-real-index/
206205
username:foo
207206
password:bar
208-
"""
209-
)
207+
""")
210208
upload_settings.create_repository = lambda: stub_repository
211209

212210
# Upload a pre-signed distribution
@@ -301,13 +299,11 @@ def test_exception_for_http_status(
301299

302300
def test_get_config_old_format(make_settings, config_file):
303301
try:
304-
make_settings(
305-
"""
302+
make_settings("""
306303
[server-login]
307304
username:foo
308305
password:bar
309-
"""
310-
)
306+
""")
311307
except KeyError as err:
312308
assert all(
313309
text in err.args[0]
@@ -322,14 +318,12 @@ def test_get_config_old_format(make_settings, config_file):
322318

323319
def test_deprecated_repo(make_settings):
324320
with pytest.raises(exceptions.UploadToDeprecatedPyPIDetected) as err:
325-
upload_settings = make_settings(
326-
"""
321+
upload_settings = make_settings("""
327322
[pypi]
328323
repository: https://pypi.python.org/pypi/
329324
username:foo
330325
password:bar
331-
"""
332-
)
326+
""")
333327

334328
upload.upload(upload_settings, [helpers.WHEEL_FIXTURE])
335329

@@ -373,14 +367,12 @@ def test_exception_for_redirect(
373367
):
374368
# Not using fixtures because this setup is significantly different
375369

376-
upload_settings = make_settings(
377-
f"""
370+
upload_settings = make_settings(f"""
378371
[pypi]
379372
repository: {repository_url}
380373
username:foo
381374
password:bar
382-
"""
383-
)
375+
""")
384376

385377
stub_response = pretend.stub(
386378
is_redirect=True,
@@ -526,8 +518,7 @@ def none_upload(*args, **settings_kwargs):
526518

527519

528520
def test_values_from_env_non_pypi(monkeypatch, write_config_file):
529-
write_config_file(
530-
"""
521+
write_config_file("""
531522
[distutils]
532523
index-servers =
533524
notpypi
@@ -536,8 +527,7 @@ def test_values_from_env_non_pypi(monkeypatch, write_config_file):
536527
repository: https://upload.example.org/legacy/
537528
username:someusername
538529
password:password
539-
"""
540-
)
530+
""")
541531

542532
def none_upload(*args, **settings_kwargs):
543533
pass

tests/test_utils.py

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,14 @@
2323

2424

2525
def test_get_config(write_config_file):
26-
config_file = write_config_file(
27-
"""
26+
config_file = write_config_file("""
2827
[distutils]
2928
index-servers = pypi
3029
3130
[pypi]
3231
username = testuser
3332
password = testpassword
34-
"""
35-
)
33+
""")
3634

3735
assert utils.get_config(config_file) == {
3836
"pypi": {
@@ -45,13 +43,11 @@ def test_get_config(write_config_file):
4543

4644
def test_get_config_no_distutils(write_config_file):
4745
"""Upload by default to PyPI if an index server is not set in .pypirc."""
48-
config_file = write_config_file(
49-
"""
46+
config_file = write_config_file("""
5047
[pypi]
5148
username = testuser
5249
password = testpassword
53-
"""
54-
)
50+
""")
5551

5652
assert utils.get_config(config_file) == {
5753
"pypi": {
@@ -68,16 +64,14 @@ def test_get_config_no_distutils(write_config_file):
6864

6965

7066
def test_get_config_no_section(write_config_file):
71-
config_file = write_config_file(
72-
"""
67+
config_file = write_config_file("""
7368
[distutils]
7469
index-servers = pypi foo
7570
7671
[pypi]
7772
username = testuser
7873
password = testpassword
79-
"""
80-
)
74+
""")
8175

8276
assert utils.get_config(config_file) == {
8377
"pypi": {
@@ -89,12 +83,10 @@ def test_get_config_no_section(write_config_file):
8983

9084

9185
def test_get_config_override_pypi_url(write_config_file):
92-
config_file = write_config_file(
93-
"""
86+
config_file = write_config_file("""
9487
[pypi]
9588
repository = http://pypiproxy
96-
"""
97-
)
89+
""")
9890

9991
assert utils.get_config(config_file)["pypi"]["repository"] == "http://pypiproxy"
10092

@@ -116,13 +108,11 @@ def test_get_config_missing(config_file):
116108

117109
def test_empty_userpass(write_config_file):
118110
"""Suppress prompts if empty username and password are provided in .pypirc."""
119-
config_file = write_config_file(
120-
"""
111+
config_file = write_config_file("""
121112
[pypi]
122113
username=
123114
password=
124-
"""
125-
)
115+
""")
126116

127117
config = utils.get_config(config_file)
128118
pypi = config["pypi"]

0 commit comments

Comments
 (0)