Remove unnecessary expect_error.

This commit is contained in:
Chris Hunt 2019-08-10 22:04:44 -04:00
parent e4c32b9917
commit 0a6b3cedae
14 changed files with 56 additions and 71 deletions

View File

@ -166,7 +166,7 @@ def test_check_complicated_name_clean(script):
)
assert "Successfully installed dependency-b-1.0" in result.stdout
result = script.pip('check', expect_error=True)
result = script.pip('check')
expected_lines = (
"No broken requirements found.",
)

View File

@ -65,7 +65,7 @@ def test_completion_alone(script):
"""
Test getting completion for none shell, just pip completion
"""
result = script.pip('completion', expect_error=True)
result = script.pip('completion', allow_stderr_error=True)
assert 'ERROR: You must pass --bash or --fish or --zsh' in result.stderr, \
'completion alone failed -- ' + result.stderr

View File

@ -21,7 +21,7 @@ def test_download_if_requested(script):
It should download (in the scratch path) and not install if requested.
"""
result = script.pip(
'download', '-d', 'pip_downloads', 'INITools==0.1', expect_error=True
'download', '-d', 'pip_downloads', 'INITools==0.1'
)
assert Path('scratch') / 'pip_downloads' / 'INITools-0.1.tar.gz' \
in result.files_created
@ -68,7 +68,6 @@ def test_single_download_from_requirements_file(script):
"""))
result = script.pip(
'download', '-r', script.scratch_path / 'test-req.txt', '-d', '.',
expect_error=True,
)
assert Path('scratch') / 'INITools-0.1.tar.gz' in result.files_created
assert script.site_packages / 'initools' not in result.files_created
@ -80,7 +79,7 @@ def test_basic_download_should_download_dependencies(script):
It should download dependencies (in the scratch path)
"""
result = script.pip(
'download', 'Paste[openid]==1.7.5.1', '-d', '.', expect_error=True,
'download', 'Paste[openid]==1.7.5.1', '-d', '.'
)
assert Path('scratch') / 'Paste-1.7.5.1.tar.gz' in result.files_created
openid_tarball_prefix = str(Path('scratch') / 'python-openid-')
@ -129,7 +128,6 @@ def test_download_should_skip_existing_files(script):
result = script.pip(
'download', '-r', script.scratch_path / 'test-req.txt', '-d', '.',
expect_error=True,
)
assert Path('scratch') / 'INITools-0.1.tar.gz' in result.files_created
assert script.site_packages / 'initools' not in result.files_created
@ -143,7 +141,6 @@ def test_download_should_skip_existing_files(script):
# only the second package should be downloaded
result = script.pip(
'download', '-r', script.scratch_path / 'test-req.txt', '-d', '.',
expect_error=True,
)
openid_tarball_prefix = str(Path('scratch') / 'python-openid-')
assert any(
@ -387,7 +384,6 @@ class TestDownloadPlatformManylinuxes(object):
'--dest', '.',
'--platform', 'linux_x86_64',
'fake',
expect_error=True,
)
@ -571,7 +567,6 @@ def test_download_specify_abi(script, data):
'--dest', '.',
'--abi', 'cp27m',
'fake',
expect_error=True,
)
data.reset()

View File

@ -262,7 +262,7 @@ def _test_install_editable_from_git(script, tmpdir):
"""Test cloning from Git."""
pkg_path = _create_test_package(script, name='testpackage', vcs='git')
args = ['install', '-e', 'git+%s#egg=testpackage' % path_to_url(pkg_path)]
result = script.pip(*args, **{"expect_error": True})
result = script.pip(*args)
result.assert_installed('testpackage', with_files=['.git'])
@ -331,7 +331,7 @@ def test_basic_install_editable_from_hg(script, tmpdir):
"""Test cloning from Mercurial."""
pkg_path = _create_test_package(script, name='testpackage', vcs='hg')
args = ['install', '-e', 'hg+%s#egg=testpackage' % path_to_url(pkg_path)]
result = script.pip(*args, **{"expect_error": True})
result = script.pip(*args)
result.assert_installed('testpackage', with_files=['.hg'])
@ -342,7 +342,7 @@ def test_vcs_url_final_slash_normalization(script, tmpdir):
"""
pkg_path = _create_test_package(script, name='testpackage', vcs='hg')
args = ['install', '-e', 'hg+%s/#egg=testpackage' % path_to_url(pkg_path)]
result = script.pip(*args, **{"expect_error": True})
result = script.pip(*args)
result.assert_installed('testpackage', with_files=['.hg'])
@ -351,7 +351,7 @@ def test_install_editable_from_bazaar(script, tmpdir):
"""Test checking out from Bazaar."""
pkg_path = _create_test_package(script, name='testpackage', vcs='bazaar')
args = ['install', '-e', 'bzr+%s/#egg=testpackage' % path_to_url(pkg_path)]
result = script.pip(*args, **{"expect_error": True})
result = script.pip(*args)
result.assert_installed('testpackage', with_files=['.bzr'])
@ -1264,8 +1264,8 @@ def test_install_editable_with_wrong_egg_name(script):
version='0.1')
"""))
result = script.pip(
'install', '--editable', 'file://%s#egg=pkgb' % pkga_path,
expect_error=True)
'install', '--editable', 'file://%s#egg=pkgb' % pkga_path
)
assert ("Generating metadata for package pkgb produced metadata "
"for project name pkga. Fix your #egg=pkgb "
"fragments.") in result.stderr
@ -1368,7 +1368,7 @@ def test_install_compatible_python_requires(script):
python_requires='>1.0',
version='0.1')
"""))
res = script.pip('install', pkga_path, expect_error=True)
res = script.pip('install', pkga_path)
assert "Successfully installed pkga-0.1" in res.stdout, res
@ -1424,7 +1424,7 @@ def test_install_from_test_pypi_with_ext_url_dep_is_blocked(script, index):
def test_installing_scripts_outside_path_prints_warning(script):
result = script.pip_install_local(
"--prefix", script.scratch_path, "script_wheel1", expect_error=True
"--prefix", script.scratch_path, "script_wheel1"
)
assert "Successfully installed script-wheel1" in result.stdout, str(result)
assert "--no-warn-script-location" in result.stderr

View File

@ -31,7 +31,11 @@ def test_check_install_canonicalization(script, deprecated_python):
# Install the first missing dependency. Only an error for the
# second dependency should remain.
result = script.pip(
'install', '--no-index', normal_path, '--quiet', expect_error=True
'install',
'--no-index',
normal_path,
'--quiet',
allow_stderr_error=True,
)
expected_lines = [
"ERROR: pkga 1.0 requires SPECIAL.missing, which is not installed.",
@ -87,7 +91,7 @@ def test_check_install_does_not_warn_for_out_of_graph_issues(
# Install conflict package
result = script.pip(
'install', '--no-index', pkg_conflict_path, expect_error=True,
'install', '--no-index', pkg_conflict_path, allow_stderr_error=True,
)
assert matches_expected_lines(result.stderr, [
"ERROR: broken 1.0 requires missing, which is not installed.",

View File

@ -51,7 +51,6 @@ def test_cleanup_after_install_editable_from_hg(script, tmpdir):
'hg+https://bitbucket.org/ianb/scripttest',
tmpdir.joinpath("cache"),
),
expect_error=True,
)
build = script.venv_path / 'build'
src = script.venv_path / 'src'

View File

@ -21,7 +21,7 @@ def test_debian_egg_name_workaround(script):
https://bitbucket.org/ianb/pip/issue/104/pip-uninstall-on-ubuntu-linux
"""
result = script.pip('install', 'INITools==0.2', expect_error=True)
result = script.pip('install', 'INITools==0.2')
egg_info = os.path.join(
script.site_packages, "INITools-0.2-py%s.egg-info" % pyversion)

View File

@ -74,7 +74,7 @@ def _test_env_vars_override_config_file(script, virtualenv, config_file):
)
script.environ['PIP_NO_INDEX'] = '0'
virtualenv.clear()
result = script.pip('install', '-vvv', 'INITools', expect_error=True)
result = script.pip('install', '-vvv', 'INITools')
assert "Successfully installed INITools" in result.stdout
@ -89,7 +89,6 @@ def test_command_line_append_flags(script, virtualenv, data):
result = script.pip(
'install', '-vvv', 'INITools', '--trusted-host',
'test.pypi.org',
expect_error=True,
)
assert (
"Analyzing links from page https://test.pypi.org"
@ -99,7 +98,6 @@ def test_command_line_append_flags(script, virtualenv, data):
result = script.pip(
'install', '-vvv', '--find-links', data.find_links, 'INITools',
'--trusted-host', 'test.pypi.org',
expect_error=True,
)
assert (
"Analyzing links from page https://test.pypi.org"
@ -123,7 +121,6 @@ def test_command_line_appends_correctly(script, data):
result = script.pip(
'install', '-vvv', 'INITools', '--trusted-host',
'test.pypi.org',
expect_error=True,
)
assert (
@ -175,7 +172,6 @@ def _test_config_file_override_stack(script, virtualenv, config_file):
result = script.pip(
'install', '-vvv', '--index-url', 'https://pypi.org/simple/',
'INITools',
expect_error=True,
)
assert (
"Getting page http://download.zope.org/ppix/INITools"

View File

@ -26,7 +26,7 @@ def check_force_reinstall(script, specifier, expected):
assert result2.files_updated, 'force-reinstall failed'
check_installed_version(script, 'simplewheel', expected)
result3 = script.pip('uninstall', 'simplewheel', '-y', expect_error=True)
result3 = script.pip('uninstall', 'simplewheel', '-y')
assert_all_changes(result, result3, [script.venv / 'build', 'cache'])

View File

@ -534,7 +534,6 @@ def test_install_options_local_to_package(script, data):
'install',
'--no-index', '-f', data.find_links,
'-r', reqs_file,
expect_error=True,
)
simple = test_simple / 'lib' / 'python' / 'simple'

View File

@ -13,8 +13,8 @@ def test_no_upgrade_unless_requested(script):
No upgrade if not specifically requested.
"""
script.pip('install', 'INITools==0.1', expect_error=True)
result = script.pip('install', 'INITools', expect_error=True)
script.pip('install', 'INITools==0.1')
result = script.pip('install', 'INITools')
assert not result.files_created, (
'pip install INITools upgraded when it should not have'
)
@ -39,10 +39,9 @@ def test_only_if_needed_does_not_upgrade_deps_when_satisfied(script):
It doesn't upgrade a dependency if it already satisfies the requirements.
"""
script.pip_install_local('simple==2.0', expect_error=True)
script.pip_install_local('simple==2.0')
result = script.pip_install_local(
'--upgrade', '--upgrade-strategy=only-if-needed', 'require_simple',
expect_error=True
'--upgrade', '--upgrade-strategy=only-if-needed', 'require_simple'
)
assert (
@ -64,10 +63,9 @@ def test_only_if_needed_does_upgrade_deps_when_no_longer_satisfied(script):
It does upgrade a dependency if it no longer satisfies the requirements.
"""
script.pip_install_local('simple==1.0', expect_error=True)
script.pip_install_local('simple==1.0')
result = script.pip_install_local(
'--upgrade', '--upgrade-strategy=only-if-needed', 'require_simple',
expect_error=True
'--upgrade', '--upgrade-strategy=only-if-needed', 'require_simple'
)
assert (
@ -89,10 +87,9 @@ def test_eager_does_upgrade_dependecies_when_currently_satisfied(script):
It does upgrade a dependency even if it already satisfies the requirements.
"""
script.pip_install_local('simple==2.0', expect_error=True)
script.pip_install_local('simple==2.0')
result = script.pip_install_local(
'--upgrade', '--upgrade-strategy=eager', 'require_simple',
expect_error=True
'--upgrade', '--upgrade-strategy=eager', 'require_simple'
)
assert (
@ -110,10 +107,9 @@ def test_eager_does_upgrade_dependecies_when_no_longer_satisfied(script):
It does upgrade a dependency if it no longer satisfies the requirements.
"""
script.pip_install_local('simple==1.0', expect_error=True)
script.pip_install_local('simple==1.0')
result = script.pip_install_local(
'--upgrade', '--upgrade-strategy=eager', 'require_simple',
expect_error=True
'--upgrade', '--upgrade-strategy=eager', 'require_simple'
)
assert (
@ -136,8 +132,8 @@ def test_upgrade_to_specific_version(script):
It does upgrade to specific version requested.
"""
script.pip('install', 'INITools==0.1', expect_error=True)
result = script.pip('install', 'INITools==0.2', expect_error=True)
script.pip('install', 'INITools==0.1')
result = script.pip('install', 'INITools==0.2')
assert result.files_created, (
'pip install with specific version did not upgrade'
)
@ -157,8 +153,8 @@ def test_upgrade_if_requested(script):
And it does upgrade if requested.
"""
script.pip('install', 'INITools==0.1', expect_error=True)
result = script.pip('install', '--upgrade', 'INITools', expect_error=True)
script.pip('install', 'INITools==0.1')
result = script.pip('install', '--upgrade', 'INITools')
assert result.files_created, 'pip install --upgrade did not upgrade'
assert (
script.site_packages / 'INITools-0.1-py%s.egg-info' %
@ -193,7 +189,7 @@ def test_upgrade_force_reinstall_newest(script):
'install', '--upgrade', '--force-reinstall', 'INITools'
)
assert result2.files_updated, 'upgrade to INITools 0.3 failed'
result3 = script.pip('uninstall', 'initools', '-y', expect_error=True)
result3 = script.pip('uninstall', 'initools', '-y')
assert_all_changes(result, result3, [script.venv / 'build', 'cache'])
@ -203,13 +199,13 @@ def test_uninstall_before_upgrade(script):
Automatic uninstall-before-upgrade.
"""
result = script.pip('install', 'INITools==0.2', expect_error=True)
result = script.pip('install', 'INITools==0.2')
assert script.site_packages / 'initools' in result.files_created, (
sorted(result.files_created.keys())
)
result2 = script.pip('install', 'INITools==0.3', expect_error=True)
result2 = script.pip('install', 'INITools==0.3')
assert result2.files_created, 'upgrade to INITools 0.3 failed'
result3 = script.pip('uninstall', 'initools', '-y', expect_error=True)
result3 = script.pip('uninstall', 'initools', '-y')
assert_all_changes(result, result3, [script.venv / 'build', 'cache'])
@ -219,7 +215,7 @@ def test_uninstall_before_upgrade_from_url(script):
Automatic uninstall-before-upgrade from URL.
"""
result = script.pip('install', 'INITools==0.2', expect_error=True)
result = script.pip('install', 'INITools==0.2')
assert script.site_packages / 'initools' in result.files_created, (
sorted(result.files_created.keys())
)
@ -227,10 +223,9 @@ def test_uninstall_before_upgrade_from_url(script):
'install',
'https://files.pythonhosted.org/packages/source/I/INITools/INITools-'
'0.3.tar.gz',
expect_error=True,
)
assert result2.files_created, 'upgrade to INITools 0.3 failed'
result3 = script.pip('uninstall', 'initools', '-y', expect_error=True)
result3 = script.pip('uninstall', 'initools', '-y')
assert_all_changes(result, result3, [script.venv / 'build', 'cache'])
@ -241,7 +236,7 @@ def test_upgrade_to_same_version_from_url(script):
need to uninstall and reinstall if --upgrade is not specified.
"""
result = script.pip('install', 'INITools==0.3', expect_error=True)
result = script.pip('install', 'INITools==0.3')
assert script.site_packages / 'initools' in result.files_created, (
sorted(result.files_created.keys())
)
@ -249,10 +244,9 @@ def test_upgrade_to_same_version_from_url(script):
'install',
'https://files.pythonhosted.org/packages/source/I/INITools/INITools-'
'0.3.tar.gz',
expect_error=True,
)
assert not result2.files_updated, 'INITools 0.3 reinstalled same version'
result3 = script.pip('uninstall', 'initools', '-y', expect_error=True)
result3 = script.pip('uninstall', 'initools', '-y')
assert_all_changes(result, result3, [script.venv / 'build', 'cache'])
@ -321,9 +315,9 @@ def test_should_not_install_always_from_cache(script):
If there is an old cached package, pip should download the newer version
Related to issue #175
"""
script.pip('install', 'INITools==0.2', expect_error=True)
script.pip('install', 'INITools==0.2')
script.pip('uninstall', '-y', 'INITools')
result = script.pip('install', 'INITools==0.1', expect_error=True)
result = script.pip('install', 'INITools==0.1')
assert (
script.site_packages / 'INITools-0.2-py%s.egg-info' %
pyversion not in result.files_created
@ -339,8 +333,8 @@ def test_install_with_ignoreinstalled_requested(script):
"""
Test old conflicting package is completely ignored
"""
script.pip('install', 'INITools==0.1', expect_error=True)
result = script.pip('install', '-I', 'INITools==0.3', expect_error=True)
script.pip('install', 'INITools==0.1')
result = script.pip('install', '-I', 'INITools==0.3')
assert result.files_created, 'pip install -I did not install'
# both the old and new metadata should be present.
assert os.path.exists(

View File

@ -412,7 +412,7 @@ def test_wheel_no_compiles_pyc(script, data):
def test_install_from_wheel_uninstalls_old_version(script, data):
# regression test for https://github.com/pypa/pip/issues/1825
package = data.packages.joinpath("simplewheel-1.0-py2.py3-none-any.whl")
result = script.pip('install', package, '--no-index', expect_error=True)
result = script.pip('install', package, '--no-index')
package = data.packages.joinpath("simplewheel-2.0-py2.py3-none-any.whl")
result = script.pip('install', package, '--no-index', expect_error=False)
dist_info_folder = script.site_packages / 'simplewheel-2.0.dist-info'

View File

@ -142,11 +142,11 @@ def test_basic_uninstall_namespace_package(script):
the namespace and everything in it.
"""
result = script.pip('install', 'pd.requires==0.0.3', expect_error=True)
result = script.pip('install', 'pd.requires==0.0.3')
assert join(script.site_packages, 'pd') in result.files_created, (
sorted(result.files_created.keys())
)
result2 = script.pip('uninstall', 'pd.find', '-y', expect_error=True)
result2 = script.pip('uninstall', 'pd.find', '-y')
assert join(script.site_packages, 'pd') not in result2.files_deleted, (
sorted(result2.files_deleted.keys())
)
@ -259,11 +259,11 @@ def test_uninstall_console_scripts(script):
"""
args = ['install']
args.append('discover')
result = script.pip(*args, **{"expect_error": True})
result = script.pip(*args)
assert script.bin / 'discover' + script.exe in result.files_created, (
sorted(result.files_created.keys())
)
result2 = script.pip('uninstall', 'discover', '-y', expect_error=True)
result2 = script.pip('uninstall', 'discover', '-y')
assert_all_changes(result, result2, [script.venv / 'build', 'cache'])
@ -272,7 +272,7 @@ def test_uninstall_easy_installed_console_scripts(script):
"""
Test uninstalling package with console_scripts that is easy_installed.
"""
result = script.easy_install('discover', expect_error=True)
result = script.easy_install('discover')
assert script.bin / 'discover' + script.exe in result.files_created, (
sorted(result.files_created.keys())
)
@ -349,8 +349,7 @@ def _test_uninstall_editable_with_source_outside_venv(
assert join(
script.site_packages, 'pip-test-package.egg-link'
) in result2.files_created, list(result2.files_created.keys())
result3 = script.pip('uninstall', '-y',
'pip-test-package', expect_error=True)
result3 = script.pip('uninstall', '-y', 'pip-test-package')
assert_all_changes(
result,
result3,

View File

@ -53,8 +53,8 @@ def _create_test_package_with_submodule(env, rel_path):
packages=find_packages(),
)
'''))
env.run('git', 'init', cwd=version_pkg_path, expect_error=True)
env.run('git', 'add', '.', cwd=version_pkg_path, expect_error=True)
env.run('git', 'init', cwd=version_pkg_path)
env.run('git', 'add', '.', cwd=version_pkg_path)
_git_commit(env, version_pkg_path, message='initial version')
submodule_path = _create_test_package_submodule(env)
@ -66,7 +66,6 @@ def _create_test_package_with_submodule(env, rel_path):
submodule_path,
rel_path,
cwd=version_pkg_path,
expect_error=True,
)
_git_commit(env, version_pkg_path, message='initial version w submodule')