Skip to content

Commit 2946038

Browse files
authored
Merge pull request #8366 from gutsytechster/add_helper_method_to_uninstall_and_wheel
Add helper methods for path lookups to test_{uninstall, wheel}.py
2 parents 63cc267 + c51c5a7 commit 2946038

File tree

3 files changed

+23
-38
lines changed

3 files changed

+23
-38
lines changed

news/b8f2cc6f-00f0-4509-baeb-2e9fd5e35bcf.trivial

Whitespace-only changes.

tests/functional/test_uninstall.py

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,7 @@ def test_basic_uninstall(script):
2828
2929
"""
3030
result = script.pip('install', 'INITools==0.2')
31-
assert join(script.site_packages, 'initools') in result.files_created, (
32-
sorted(result.files_created.keys())
33-
)
31+
result.did_create(join(script.site_packages, 'initools'))
3432
# the import forces the generation of __pycache__ if the version of python
3533
# supports it
3634
script.run('python', '-c', "import initools")
@@ -147,9 +145,7 @@ def test_basic_uninstall_namespace_package(script):
147145
148146
"""
149147
result = script.pip('install', 'pd.requires==0.0.3')
150-
assert join(script.site_packages, 'pd') in result.files_created, (
151-
sorted(result.files_created.keys())
152-
)
148+
result.did_create(join(script.site_packages, 'pd'))
153149
result2 = script.pip('uninstall', 'pd.find', '-y')
154150
assert join(script.site_packages, 'pd') not in result2.files_deleted, (
155151
sorted(result2.files_deleted.keys())
@@ -171,16 +167,12 @@ def test_uninstall_overlapping_package(script, data):
171167
child_pkg = data.packages.joinpath("child-0.1.tar.gz")
172168

173169
result1 = script.pip('install', parent_pkg)
174-
assert join(script.site_packages, 'parent') in result1.files_created, (
175-
sorted(result1.files_created.keys())
176-
)
170+
result1.did_create(join(script.site_packages, 'parent'))
177171
result2 = script.pip('install', child_pkg)
178-
assert join(script.site_packages, 'child') in result2.files_created, (
179-
sorted(result2.files_created.keys())
180-
)
181-
assert normpath(
172+
result2.did_create(join(script.site_packages, 'child'))
173+
result2.did_create(normpath(
182174
join(script.site_packages, 'parent/plugins/child_plugin.py')
183-
) in result2.files_created, sorted(result2.files_created.keys())
175+
))
184176
# The import forces the generation of __pycache__ if the version of python
185177
# supports it
186178
script.run('python', '-c', "import parent.plugins.child_plugin, child")
@@ -267,9 +259,7 @@ def test_uninstall_console_scripts(script):
267259
entry_points={'console_scripts': ['discover = discover:main']},
268260
)
269261
result = script.pip('install', pkg_path)
270-
assert script.bin / 'discover' + script.exe in result.files_created, (
271-
sorted(result.files_created.keys())
272-
)
262+
result.did_create(script.bin / 'discover' + script.exe)
273263
result2 = script.pip('uninstall', 'discover', '-y')
274264
assert_all_changes(result, result2, [script.venv / 'build', 'cache'])
275265

@@ -305,9 +295,7 @@ def test_uninstall_easy_installed_console_scripts(script):
305295
# setuptools >= 42.0.0 deprecates easy_install and prints a warning when
306296
# used
307297
result = script.easy_install('discover', allow_stderr_warning=True)
308-
assert script.bin / 'discover' + script.exe in result.files_created, (
309-
sorted(result.files_created.keys())
310-
)
298+
result.did_create(script.bin / 'discover' + script.exe)
311299
result2 = script.pip('uninstall', 'discover', '-y')
312300
assert_all_changes(
313301
result,
@@ -374,9 +362,9 @@ def _test_uninstall_editable_with_source_outside_venv(
374362
expect_stderr=True,
375363
)
376364
result2 = script.pip('install', '-e', temp_pkg_dir)
377-
assert join(
365+
result2.did_create(join(
378366
script.site_packages, 'pip-test-package.egg-link'
379-
) in result2.files_created, list(result2.files_created.keys())
367+
))
380368
result3 = script.pip('uninstall', '-y', 'pip-test-package')
381369
assert_all_changes(
382370
result,
@@ -476,7 +464,7 @@ def test_uninstall_wheel(script, data):
476464
package = data.packages.joinpath("simple.dist-0.1-py2.py3-none-any.whl")
477465
result = script.pip('install', package, '--no-index')
478466
dist_info_folder = script.site_packages / 'simple.dist-0.1.dist-info'
479-
assert dist_info_folder in result.files_created
467+
result.did_create(dist_info_folder)
480468
result2 = script.pip('uninstall', 'simple.dist', '-y')
481469
assert_all_changes(result, result2, [])
482470

tests/functional/test_wheel.py

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def test_pip_wheel_success(script, data):
5858
.format(filename=re.escape(wheel_file_name)), result.stdout)
5959
assert re.search(
6060
r"^\s+Stored in directory: ", result.stdout, re.M)
61-
assert wheel_file_path in result.files_created, result.stdout
61+
result.did_create(wheel_file_path)
6262
assert "Successfully built simple" in result.stdout, result.stdout
6363

6464

@@ -74,7 +74,7 @@ def test_pip_wheel_build_cache(script, data):
7474
wheel_file_name = 'simple-3.0-py{pyversion[0]}-none-any.whl' \
7575
.format(**globals())
7676
wheel_file_path = script.scratch / wheel_file_name
77-
assert wheel_file_path in result.files_created, result.stdout
77+
result.did_create(wheel_file_path)
7878
assert "Successfully built simple" in result.stdout, result.stdout
7979
# remove target file
8080
(script.scratch_path / wheel_file_name).unlink()
@@ -84,7 +84,7 @@ def test_pip_wheel_build_cache(script, data):
8484
'wheel', '--no-index', '-f', data.find_links,
8585
'simple==3.0',
8686
)
87-
assert wheel_file_path in result.files_created, result.stdout
87+
result.did_create(wheel_file_path)
8888
assert "Successfully built simple" not in result.stdout, result.stdout
8989

9090

@@ -97,7 +97,7 @@ def test_basic_pip_wheel_downloads_wheels(script, data):
9797
)
9898
wheel_file_name = 'simple.dist-0.1-py2.py3-none-any.whl'
9999
wheel_file_path = script.scratch / wheel_file_name
100-
assert wheel_file_path in result.files_created, result.stdout
100+
result.did_create(wheel_file_path)
101101
assert "Saved" in result.stdout, result.stdout
102102

103103

@@ -152,7 +152,7 @@ def test_pip_wheel_builds_editable_deps(script, data):
152152
wheel_file_name = 'simple-1.0-py{pyversion[0]}-none-any.whl' \
153153
.format(**globals())
154154
wheel_file_path = script.scratch / wheel_file_name
155-
assert wheel_file_path in result.files_created, result.stdout
155+
result.did_create(wheel_file_path)
156156

157157

158158
def test_pip_wheel_builds_editable(script, data):
@@ -167,7 +167,7 @@ def test_pip_wheel_builds_editable(script, data):
167167
wheel_file_name = 'simplewheel-1.0-py{pyversion[0]}-none-any.whl' \
168168
.format(**globals())
169169
wheel_file_path = script.scratch / wheel_file_name
170-
assert wheel_file_path in result.files_created, result.stdout
170+
result.did_create(wheel_file_path)
171171

172172

173173
def test_pip_wheel_fail(script, data):
@@ -182,10 +182,7 @@ def test_pip_wheel_fail(script, data):
182182
wheel_file_name = 'wheelbroken-0.1-py{pyversion[0]}-none-any.whl' \
183183
.format(**globals())
184184
wheel_file_path = script.scratch / wheel_file_name
185-
assert wheel_file_path not in result.files_created, (
186-
wheel_file_path,
187-
result.files_created,
188-
)
185+
result.did_not_create(wheel_file_path)
189186
assert "FakeError" in result.stderr, result.stderr
190187
assert "Failed to build wheelbroken" in result.stdout, result.stdout
191188
assert result.returncode != 0
@@ -226,7 +223,7 @@ def test_pip_wheel_source_deps(script, data):
226223
wheel_file_name = 'source-1.0-py{pyversion[0]}-none-any.whl' \
227224
.format(**globals())
228225
wheel_file_path = script.scratch / wheel_file_name
229-
assert wheel_file_path in result.files_created, result.stdout
226+
result.did_create(wheel_file_path)
230227
assert "Successfully built source" in result.stdout, result.stdout
231228

232229

@@ -274,7 +271,7 @@ def test_pip_wheel_with_pep518_build_reqs(script, data, common_wheels):
274271
wheel_file_name = 'pep518-3.0-py{pyversion[0]}-none-any.whl' \
275272
.format(**globals())
276273
wheel_file_path = script.scratch / wheel_file_name
277-
assert wheel_file_path in result.files_created, result.stdout
274+
result.did_create(wheel_file_path)
278275
assert "Successfully built pep518" in result.stdout, result.stdout
279276
assert "Installing build dependencies" in result.stdout, result.stdout
280277

@@ -288,7 +285,7 @@ def test_pip_wheel_with_pep518_build_reqs_no_isolation(script, data):
288285
wheel_file_name = 'pep518-3.0-py{pyversion[0]}-none-any.whl' \
289286
.format(**globals())
290287
wheel_file_path = script.scratch / wheel_file_name
291-
assert wheel_file_path in result.files_created, result.stdout
288+
result.did_create(wheel_file_path)
292289
assert "Successfully built pep518" in result.stdout, result.stdout
293290
assert "Installing build dependencies" not in result.stdout, result.stdout
294291

@@ -335,7 +332,7 @@ def test_pep517_wheels_are_not_confused_with_other_files(script, tmpdir, data):
335332
wheel_file_name = 'withpyproject-0.0.1-py{pyversion[0]}-none-any.whl' \
336333
.format(**globals())
337334
wheel_file_path = script.scratch / wheel_file_name
338-
assert wheel_file_path in result.files_created, result.stdout
335+
result.did_create(wheel_file_path)
339336

340337

341338
def test_legacy_wheels_are_not_confused_with_other_files(script, tmpdir, data):
@@ -350,4 +347,4 @@ def test_legacy_wheels_are_not_confused_with_other_files(script, tmpdir, data):
350347
wheel_file_name = 'simplewheel-1.0-py{pyversion[0]}-none-any.whl' \
351348
.format(**globals())
352349
wheel_file_path = script.scratch / wheel_file_name
353-
assert wheel_file_path in result.files_created, result.stdout
350+
result.did_create(wheel_file_path)

0 commit comments

Comments
 (0)