@@ -13,8 +13,8 @@ def test_version_compare():
13
13
Test version comparison.
14
14
15
15
"""
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"
18
18
19
19
20
20
def test_pypi_xml_transformation ():
@@ -24,32 +24,32 @@ def test_pypi_xml_transformation():
24
24
"""
25
25
pypi_hits = [
26
26
{
27
- ' name' : ' foo' ,
28
- ' summary' : ' foo summary' ,
29
- ' version' : ' 1.0' ,
27
+ " name" : " foo" ,
28
+ " summary" : " foo summary" ,
29
+ " version" : " 1.0" ,
30
30
},
31
31
{
32
- ' name' : ' foo' ,
33
- ' summary' : ' foo summary v2' ,
34
- ' version' : ' 2.0' ,
32
+ " name" : " foo" ,
33
+ " summary" : " foo summary v2" ,
34
+ " version" : " 2.0" ,
35
35
},
36
36
{
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" ,
41
41
},
42
42
]
43
43
expected = [
44
44
{
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" ,
48
48
},
49
49
{
50
- ' versions' : [' 1.0' ],
51
- ' name' : ' bar' ,
52
- ' summary' : ' bar summary' ,
50
+ " versions" : [" 1.0" ],
51
+ " name" : " bar" ,
52
+ " summary" : " bar summary" ,
53
53
},
54
54
]
55
55
assert transform_hits (pypi_hits ) == expected
@@ -62,41 +62,41 @@ def test_basic_search(script):
62
62
End to end test of search command.
63
63
64
64
"""
65
- output = script .pip (' search' , ' pip' )
65
+ output = script .pip (" search" , " pip" )
66
66
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
69
68
)
70
69
71
70
72
71
@pytest .mark .network
73
72
@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
+ ),
78
79
)
79
80
@pytest .mark .search
80
81
def test_multiple_search (script ):
81
82
"""
82
83
Test searching for multiple packages at once.
83
84
84
85
"""
85
- output = script .pip (' search' , ' pip' , ' INITools' )
86
+ output = script .pip (" search" , " pip" , " INITools" )
86
87
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
89
89
)
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
91
91
92
92
93
93
@pytest .mark .search
94
94
def test_search_missing_argument (script ):
95
95
"""
96
96
Test missing required argument for search
97
97
"""
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
100
100
101
101
102
102
@pytest .mark .network
@@ -105,7 +105,7 @@ def test_run_method_should_return_success_when_find_packages():
105
105
"""
106
106
Test SearchCommand.run for found package
107
107
"""
108
- command = create_command (' search' )
108
+ command = create_command (" search" )
109
109
cmdline = "--index=https://pypi.org/pypi pip"
110
110
with command .main_context ():
111
111
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():
119
119
"""
120
120
Test SearchCommand.run for no matches
121
121
"""
122
- command = create_command (' search' )
122
+ command = create_command (" search" )
123
123
cmdline = "--index=https://pypi.org/pypi nonexistentpackage"
124
124
with command .main_context ():
125
125
options , args = command .parse_args (cmdline .split ())
@@ -133,7 +133,7 @@ def test_search_should_exit_status_code_zero_when_find_packages(script):
133
133
"""
134
134
Test search exit status code for package found
135
135
"""
136
- result = script .pip (' search' , ' pip' )
136
+ result = script .pip (" search" , " pip" )
137
137
assert result .returncode == SUCCESS
138
138
139
139
@@ -143,7 +143,7 @@ def test_search_exit_status_code_when_finds_no_package(script):
143
143
"""
144
144
Test search exit status code for no matches
145
145
"""
146
- result = script .pip (' search' , ' nonexistentpackage' , expect_error = True )
146
+ result = script .pip (" search" , " nonexistentpackage" , expect_error = True )
147
147
assert result .returncode == NO_MATCHES_FOUND , result .returncode
148
148
149
149
@@ -154,26 +154,24 @@ def test_latest_prerelease_install_message(caplog, monkeypatch):
154
154
"""
155
155
hits = [
156
156
{
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" ],
160
160
}
161
161
]
162
162
163
163
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 ])
166
165
167
166
dist = pretend .stub (version = "1.0.0" )
168
167
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 )
171
169
with caplog .at_level (logging .INFO ):
172
170
print_results (hits )
173
171
174
172
message = caplog .records [- 1 ].getMessage ()
175
173
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" )]
177
175
178
176
179
177
@pytest .mark .search
@@ -183,20 +181,20 @@ def test_search_print_results_should_contain_latest_versions(caplog):
183
181
"""
184
182
hits = [
185
183
{
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" ],
189
187
},
190
188
{
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
+ },
195
193
]
196
194
197
195
with caplog .at_level (logging .INFO ):
198
196
print_results (hits )
199
197
200
198
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