Skip to content

Commit

Permalink
Drop python2 related stuff in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hexagonrecursion committed Feb 10, 2021
1 parent bbf8466 commit ad05718
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 61 deletions.
Empty file.
15 changes: 2 additions & 13 deletions tests/functional/test_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@
need_svn,
path_to_url,
pyversion,
pyversion_tuple,
requirements_file,
windows_workaround_7667,
)
from tests.lib.filesystem import make_socket_file
from tests.lib.local_repos import local_checkout
Expand Down Expand Up @@ -193,16 +191,10 @@ def test_pip_second_command_line_interface_works(
"""
# Re-install pip so we get the launchers.
script.pip_install_local('-f', common_wheels, pip_src)
# On old versions of Python, urllib3/requests will raise a warning about
# the lack of an SSLContext.
kwargs = {'expect_stderr': deprecated_python}
if pyversion_tuple < (2, 7, 9):
kwargs['expect_stderr'] = True

args = ['pip{pyversion}'.format(**globals())]
args.extend(['install', 'INITools==0.2'])
args.extend(['-f', data.packages])
result = script.run(*args, **kwargs)
result = script.run(*args)
dist_info_folder = (
script.site_packages /
'INITools-0.2.dist-info'
Expand Down Expand Up @@ -581,7 +573,7 @@ def test_install_from_local_directory_with_symlinks_to_directories(
result.did_create(dist_info_folder)


@pytest.mark.skipif("sys.platform == 'win32' or sys.version_info < (3,)")
@pytest.mark.skipif("sys.platform == 'win32'")
def test_install_from_local_directory_with_socket_file(
script, data, tmpdir, with_wheel
):
Expand Down Expand Up @@ -743,7 +735,6 @@ def test_install_using_install_option_and_editable(script, tmpdir):
@pytest.mark.xfail
@pytest.mark.network
@need_mercurial
@windows_workaround_7667
def test_install_global_option_using_editable(script, tmpdir):
"""
Test using global distutils options, but in an editable installation
Expand Down Expand Up @@ -1392,7 +1383,6 @@ def test_install_no_binary_disables_building_wheels(script, data, with_wheel):


@pytest.mark.network
@windows_workaround_7667
def test_install_no_binary_builds_pep_517_wheel(script, data, with_wheel):
to_install = data.packages.joinpath('pep517_setup_and_pyproject')
res = script.pip(
Expand All @@ -1407,7 +1397,6 @@ def test_install_no_binary_builds_pep_517_wheel(script, data, with_wheel):


@pytest.mark.network
@windows_workaround_7667
def test_install_no_binary_uses_local_backend(
script, data, with_wheel, tmpdir):
to_install = data.packages.joinpath('pep517_wrapper_buildsys')
Expand Down
3 changes: 1 addition & 2 deletions tests/functional/test_pep517.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from pip._internal.build_env import BuildEnvironment
from pip._internal.req import InstallRequirement
from tests.lib import make_test_finder, path_to_url, windows_workaround_7667
from tests.lib import make_test_finder, path_to_url


def make_project(tmpdir, requires=None, backend=None, backend_path=None):
Expand Down Expand Up @@ -255,7 +255,6 @@ def test_explicit_setuptools_backend(script, tmpdir, data, common_wheels):


@pytest.mark.network
@windows_workaround_7667
def test_pep517_and_build_options(script, tmpdir, data, common_wheels):
"""Backend generated requirements are installed in the build env"""
project_dir, name = make_pyproject_with_setup(tmpdir)
Expand Down
8 changes: 0 additions & 8 deletions tests/lib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
SRC_DIR = Path(__file__).resolve().parent.parent.parent

pyversion = get_major_minor_version()
pyversion_tuple = sys.version_info

CURRENT_PY_VERSION_INFO = sys.version_info[:3]

Expand Down Expand Up @@ -1157,10 +1156,3 @@ def need_mercurial(fn):
return pytest.mark.mercurial(need_executable(
'Mercurial', ('hg', 'version')
)(fn))


# Workaround for test failures after new wheel release.
windows_workaround_7667 = pytest.mark.skipif(
"sys.platform == 'win32' and sys.version_info < (3,)",
reason="Workaround for #7667",
)
4 changes: 2 additions & 2 deletions tests/unit/test_operations_prepare.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def test_copy_source_tree(clean_project, tmpdir):
assert expected_files == copied_files


@pytest.mark.skipif("sys.platform == 'win32' or sys.version_info < (3,)")
@pytest.mark.skipif("sys.platform == 'win32'")
def test_copy_source_tree_with_socket(clean_project, tmpdir, caplog):
target = tmpdir.joinpath("target")
expected_files = get_filelist(clean_project)
Expand All @@ -121,7 +121,7 @@ def test_copy_source_tree_with_socket(clean_project, tmpdir, caplog):
assert socket_path in record.message


@pytest.mark.skipif("sys.platform == 'win32' or sys.version_info < (3,)")
@pytest.mark.skipif("sys.platform == 'win32'")
def test_copy_source_tree_with_socket_fails_with_no_socket_error(
clean_project, tmpdir
):
Expand Down
36 changes: 0 additions & 36 deletions tests/unit/test_utils_subprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,6 @@ def test_make_subprocess_output_error__non_ascii_command_arg(monkeypatch):
Test a command argument with a non-ascii character.
"""
cmd_args = ['foo', 'déf']
if sys.version_info[0] == 2:
# Check in Python 2 that the str (bytes object) with the non-ascii
# character has the encoding we expect. (This comes from the source
# code encoding at the top of the file.)
assert cmd_args[1].decode('utf-8') == 'déf'

# We need to monkeypatch so the encoding will be correct on Windows.
monkeypatch.setattr(locale, 'getpreferredencoding', lambda: 'utf-8')
Expand All @@ -80,7 +75,6 @@ def test_make_subprocess_output_error__non_ascii_command_arg(monkeypatch):
assert actual == expected, f'actual: {actual}'


@pytest.mark.skipif("sys.version_info < (3,)")
def test_make_subprocess_output_error__non_ascii_cwd_python_3(monkeypatch):
"""
Test a str (text) cwd with a non-ascii character in Python 3.
Expand All @@ -102,36 +96,6 @@ def test_make_subprocess_output_error__non_ascii_cwd_python_3(monkeypatch):
assert actual == expected, f'actual: {actual}'


@pytest.mark.parametrize('encoding', [
'utf-8',
# Test a Windows encoding.
'cp1252',
])
@pytest.mark.skipif("sys.version_info >= (3,)")
def test_make_subprocess_output_error__non_ascii_cwd_python_2(
monkeypatch, encoding,
):
"""
Test a str (bytes object) cwd with a non-ascii character in Python 2.
"""
cmd_args = ['test']
cwd = '/path/to/cwd/déf'.encode(encoding)
monkeypatch.setattr(sys, 'getfilesystemencoding', lambda: encoding)
actual = make_subprocess_output_error(
cmd_args=cmd_args,
cwd=cwd,
lines=[],
exit_status=1,
)
expected = dedent("""\
Command errored out with exit status 1:
command: test
cwd: /path/to/cwd/déf
Complete output (0 lines):
----------------------------------------""")
assert actual == expected, f'actual: {actual}'


# This test is mainly important for checking unicode in Python 2.
def test_make_subprocess_output_error__non_ascii_line():
"""
Expand Down

0 comments on commit ad05718

Please sign in to comment.