Skip to content

Commit fcc61e8

Browse files
authored
Merge pull request #10339 from nipunn1313/blacken_tests38
2 parents c9a07b4 + dc9ef9d commit fcc61e8

File tree

1 file changed

+50
-52
lines changed

1 file changed

+50
-52
lines changed

tests/functional/test_search.py

Lines changed: 50 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ def test_version_compare():
1313
Test version comparison.
1414
1515
"""
16-
assert highest_version(['1.0', '2.0', '0.1']) == '2.0'
17-
assert highest_version(['1.0a1', '1.0']) == '1.0'
16+
assert highest_version(["1.0", "2.0", "0.1"]) == "2.0"
17+
assert highest_version(["1.0a1", "1.0"]) == "1.0"
1818

1919

2020
def test_pypi_xml_transformation():
@@ -24,32 +24,32 @@ def test_pypi_xml_transformation():
2424
"""
2525
pypi_hits = [
2626
{
27-
'name': 'foo',
28-
'summary': 'foo summary',
29-
'version': '1.0',
27+
"name": "foo",
28+
"summary": "foo summary",
29+
"version": "1.0",
3030
},
3131
{
32-
'name': 'foo',
33-
'summary': 'foo summary v2',
34-
'version': '2.0',
32+
"name": "foo",
33+
"summary": "foo summary v2",
34+
"version": "2.0",
3535
},
3636
{
37-
'_pypi_ordering': 50,
38-
'name': 'bar',
39-
'summary': 'bar summary',
40-
'version': '1.0',
37+
"_pypi_ordering": 50,
38+
"name": "bar",
39+
"summary": "bar summary",
40+
"version": "1.0",
4141
},
4242
]
4343
expected = [
4444
{
45-
'versions': ['1.0', '2.0'],
46-
'name': 'foo',
47-
'summary': 'foo summary v2',
45+
"versions": ["1.0", "2.0"],
46+
"name": "foo",
47+
"summary": "foo summary v2",
4848
},
4949
{
50-
'versions': ['1.0'],
51-
'name': 'bar',
52-
'summary': 'bar summary',
50+
"versions": ["1.0"],
51+
"name": "bar",
52+
"summary": "bar summary",
5353
},
5454
]
5555
assert transform_hits(pypi_hits) == expected
@@ -62,41 +62,41 @@ def test_basic_search(script):
6262
End to end test of search command.
6363
6464
"""
65-
output = script.pip('search', 'pip')
65+
output = script.pip("search", "pip")
6666
assert (
67-
'The PyPA recommended tool for installing '
68-
'Python packages.' in output.stdout
67+
"The PyPA recommended tool for installing Python packages." in output.stdout
6968
)
7069

7170

7271
@pytest.mark.network
7372
@pytest.mark.skip(
74-
reason=("Warehouse search behavior is different and no longer returns "
75-
"multiple results. See "
76-
"https://github.com/pypa/warehouse/issues/3717 for more "
77-
"information."),
73+
reason=(
74+
"Warehouse search behavior is different and no longer returns "
75+
"multiple results. See "
76+
"https://github.com/pypa/warehouse/issues/3717 for more "
77+
"information."
78+
),
7879
)
7980
@pytest.mark.search
8081
def test_multiple_search(script):
8182
"""
8283
Test searching for multiple packages at once.
8384
8485
"""
85-
output = script.pip('search', 'pip', 'INITools')
86+
output = script.pip("search", "pip", "INITools")
8687
assert (
87-
'The PyPA recommended tool for installing '
88-
'Python packages.' in output.stdout
88+
"The PyPA recommended tool for installing Python packages." in output.stdout
8989
)
90-
assert 'Tools for parsing and using INI-style files' in output.stdout
90+
assert "Tools for parsing and using INI-style files" in output.stdout
9191

9292

9393
@pytest.mark.search
9494
def test_search_missing_argument(script):
9595
"""
9696
Test missing required argument for search
9797
"""
98-
result = script.pip('search', expect_error=True)
99-
assert 'ERROR: Missing required argument (search query).' in result.stderr
98+
result = script.pip("search", expect_error=True)
99+
assert "ERROR: Missing required argument (search query)." in result.stderr
100100

101101

102102
@pytest.mark.network
@@ -105,7 +105,7 @@ def test_run_method_should_return_success_when_find_packages():
105105
"""
106106
Test SearchCommand.run for found package
107107
"""
108-
command = create_command('search')
108+
command = create_command("search")
109109
cmdline = "--index=https://pypi.org/pypi pip"
110110
with command.main_context():
111111
options, args = command.parse_args(cmdline.split())
@@ -119,7 +119,7 @@ def test_run_method_should_return_no_matches_found_when_does_not_find_pkgs():
119119
"""
120120
Test SearchCommand.run for no matches
121121
"""
122-
command = create_command('search')
122+
command = create_command("search")
123123
cmdline = "--index=https://pypi.org/pypi nonexistentpackage"
124124
with command.main_context():
125125
options, args = command.parse_args(cmdline.split())
@@ -133,7 +133,7 @@ def test_search_should_exit_status_code_zero_when_find_packages(script):
133133
"""
134134
Test search exit status code for package found
135135
"""
136-
result = script.pip('search', 'pip')
136+
result = script.pip("search", "pip")
137137
assert result.returncode == SUCCESS
138138

139139

@@ -143,7 +143,7 @@ def test_search_exit_status_code_when_finds_no_package(script):
143143
"""
144144
Test search exit status code for no matches
145145
"""
146-
result = script.pip('search', 'nonexistentpackage', expect_error=True)
146+
result = script.pip("search", "nonexistentpackage", expect_error=True)
147147
assert result.returncode == NO_MATCHES_FOUND, result.returncode
148148

149149

@@ -154,26 +154,24 @@ def test_latest_prerelease_install_message(caplog, monkeypatch):
154154
"""
155155
hits = [
156156
{
157-
'name': 'ni',
158-
'summary': 'For knights who say Ni!',
159-
'versions': ['1.0.0', '1.0.1a']
157+
"name": "ni",
158+
"summary": "For knights who say Ni!",
159+
"versions": ["1.0.0", "1.0.1a"],
160160
}
161161
]
162162

163163
installed_package = pretend.stub(project_name="ni")
164-
monkeypatch.setattr("pip._vendor.pkg_resources.working_set",
165-
[installed_package])
164+
monkeypatch.setattr("pip._vendor.pkg_resources.working_set", [installed_package])
166165

167166
dist = pretend.stub(version="1.0.0")
168167
get_dist = pretend.call_recorder(lambda x: dist)
169-
monkeypatch.setattr("pip._internal.commands.search.get_distribution",
170-
get_dist)
168+
monkeypatch.setattr("pip._internal.commands.search.get_distribution", get_dist)
171169
with caplog.at_level(logging.INFO):
172170
print_results(hits)
173171

174172
message = caplog.records[-1].getMessage()
175173
assert 'pre-release; install with "pip install --pre"' in message
176-
assert get_dist.calls == [pretend.call('ni')]
174+
assert get_dist.calls == [pretend.call("ni")]
177175

178176

179177
@pytest.mark.search
@@ -183,20 +181,20 @@ def test_search_print_results_should_contain_latest_versions(caplog):
183181
"""
184182
hits = [
185183
{
186-
'name': 'testlib1',
187-
'summary': 'Test library 1.',
188-
'versions': ['1.0.5', '1.0.3']
184+
"name": "testlib1",
185+
"summary": "Test library 1.",
186+
"versions": ["1.0.5", "1.0.3"],
189187
},
190188
{
191-
'name': 'testlib2',
192-
'summary': 'Test library 1.',
193-
'versions': ['2.0.1', '2.0.3']
194-
}
189+
"name": "testlib2",
190+
"summary": "Test library 1.",
191+
"versions": ["2.0.1", "2.0.3"],
192+
},
195193
]
196194

197195
with caplog.at_level(logging.INFO):
198196
print_results(hits)
199197

200198
log_messages = sorted([r.getMessage() for r in caplog.records])
201-
assert log_messages[0].startswith('testlib1 (1.0.5)')
202-
assert log_messages[1].startswith('testlib2 (2.0.3)')
199+
assert log_messages[0].startswith("testlib1 (1.0.5)")
200+
assert log_messages[1].startswith("testlib2 (2.0.3)")

0 commit comments

Comments
 (0)