Restore python3.4 support (add it back to CI) (#1965)

This commit is contained in:
Bernát Gábor 2020-10-04 18:17:24 +01:00 committed by GitHub
parent adcf327ee5
commit 06dba77aa1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 46 additions and 26 deletions

View file

@ -25,9 +25,5 @@ source =
[coverage:run]
branch = false
parallel = true
dynamic_context = test_function
source =
${_COVERAGE_SRC}
[coverage:html]
show_contexts = true

View file

@ -33,7 +33,8 @@ jobs:
- 2.7
- pypy2
include:
- { os: MacOs, py: brew@py3 }
- { os: macos, py: brew@py3 }
- { os: ubuntu, py: 3.4.10 }
steps:
- name: Install OS dependencies
run: |

View file

@ -1 +1 @@
Fix Nonetype error in cygwin if POSIX path in dest - by :user:`danyeaw`.
Fix ``None`` type error in cygwin if POSIX path in dest - by :user:`danyeaw`.

View file

@ -0,0 +1 @@
Fix Python 3.4 incompatibilities (added back to the CI) - by :user:`gaborbernat`.

View file

@ -88,7 +88,7 @@ docs =
sphinx-rtd-theme>=0.4.3
towncrier>=19.9.0rc1
testing =
coverage>=5
coverage>=4
coverage_enable_subprocess>=1
flaky>=3
pytest>=4

View file

@ -8,8 +8,6 @@ from contextlib import contextmanager
from subprocess import CalledProcessError
from threading import Lock, Thread
import six
from virtualenv.info import fs_supports_symlink
from virtualenv.seed.embed.base_embed import BaseEmbed
from virtualenv.seed.wheels import get_wheel
@ -104,7 +102,7 @@ class FromAppData(BaseEmbed):
if version is not None:
msg += " version {}".format(version)
msg += ", pip download exit code {}".format(failure.returncode)
output = failure.output if six.PY2 else (failure.output + failure.stderr)
output = failure.output if sys.version_info < (3, 5) else (failure.output + failure.stderr)
if output:
msg += "\n"
msg += output

View file

@ -6,8 +6,6 @@ import os
import sys
from operator import eq, lt
import six
from virtualenv.util.path import Path
from virtualenv.util.six import ensure_str
from virtualenv.util.subprocess import Popen, subprocess
@ -62,7 +60,7 @@ def download_wheel(distribution, version_spec, for_py_version, search_dirs, app_
out, err = process.communicate()
if process.returncode != 0:
kwargs = {"output": out}
if six.PY2:
if sys.version_info < (3, 5):
kwargs["output"] += err
else:
kwargs["stderr"] = err

View file

@ -19,6 +19,13 @@ if six.PY3:
with self.open(mode="r", encoding=encoding, errors=errors) as f:
return f.read()
def read_bytes(self):
"""
Open the file in bytes mode, read it, and close the file.
"""
with self.open(mode="rb") as f:
return f.read()
def write_text(self, data, encoding=None, errors=None):
"""
Open the file in text mode, write to it, and close the file.
@ -28,10 +35,21 @@ if six.PY3:
with self.open(mode="w", encoding=encoding, errors=errors) as f:
return f.write(data)
def write_bytes(self, data):
"""
Open the file in bytes mode, write to it, and close the file.
"""
# type-check for the buffer interface before truncating the file
view = memoryview(data)
with self.open(mode="wb") as f:
return f.write(view)
def mkdir(self, mode=0o777, parents=False, exist_ok=False):
if exist_ok and self.exists():
return
super(type(BuiltinPath()), self).mkdir(mode, parents)
try:
super(type(BuiltinPath()), self).mkdir(mode, parents)
except FileExistsError as exception:
if not exist_ok:
raise exception
else:

View file

@ -4,7 +4,7 @@ import sys
import zipfile
ABS_HERE = os.path.abspath(os.path.dirname(__file__))
NEW_IMPORT_SYSTEM = sys.version_info[0:2] > (3, 4)
NEW_IMPORT_SYSTEM = sys.version_info[0] == 3
class VersionPlatformSelect(object):

View file

@ -1,19 +1,22 @@
from __future__ import absolute_import, unicode_literals
import sys
from virtualenv import cli_run
from virtualenv.util.six import ensure_text
from virtualenv.util.subprocess import run_cmd
def test_app_data_pinning(tmp_path):
result = cli_run([ensure_text(str(tmp_path)), "--pip", "19.3.1", "--activators", "", "--seeder", "app-data"])
version = "19.1.1" if sys.version_info[0:2] == (3, 4) else "19.3.1"
result = cli_run([ensure_text(str(tmp_path)), "--pip", version, "--activators", "", "--seeder", "app-data"])
code, out, err = run_cmd([str(result.creator.script("pip")), "list", "--disable-pip-version-check"])
assert not code
assert not err
for line in out.splitlines():
parts = line.split()
if parts and parts[0] == "pip":
assert parts[1] == "19.3.1"
assert parts[1] == version
break
else:
assert not out

View file

@ -127,6 +127,8 @@ _VENV_BUG_ON = (
ids=lambda i: "-".join(i) if isinstance(i, tuple) else i,
)
def test_create_no_seed(python, creator, isolated, system, coverage_env, special_name_dir):
if creator[0] == "venv" and sys.version_info[0:2] == (3, 4): # venv on python3.4 only supports ascii chars
special_name_dir = special_name_dir.with_name(special_name_dir.name.encode("ascii", errors="ignore").decode())
dest = special_name_dir
creator_key, method = creator
cmd = [

View file

@ -22,6 +22,7 @@ def test_seed_link_via_app_data(tmp_path, coverage_env, current_fastest, copies)
bundle_ver = BUNDLE_SUPPORT[current.version_release_str]
create_cmd = [
ensure_text(str(tmp_path / "en v")), # space in the name to ensure generated scripts work when path has space
"--no-periodic-update",
"--seeder",
"app-data",
"--extra-search-dir",

View file

@ -41,7 +41,7 @@ def test_base_bootstrap_via_pip_invoke(tmp_path, coverage_env, mocker, current_f
expected_list = list(
itertools.chain.from_iterable(["--find-links", str(e)] for e in sorted(expected, key=lambda x: str(x))),
)
found = cmd[-len(expected_list) :]
found = cmd[-len(expected_list) :] if expected_list else []
assert "--no-index" not in cmd
cmd.append("--no-index")
assert found == expected_list

View file

@ -5,7 +5,6 @@ from subprocess import CalledProcessError
import pytest
from virtualenv.info import PY2
from virtualenv.seed.wheels.acquire import download_wheel, pip_wheel_env_run
from virtualenv.seed.wheels.embed import BUNDLE_FOLDER, get_embed_wheel
from virtualenv.seed.wheels.util import discover_wheels
@ -44,7 +43,7 @@ def test_download_fails(mocker, for_py_version, session_app_data):
with pytest.raises(CalledProcessError) as context:
download_wheel("pip", "==1", for_py_version, [], session_app_data, as_path),
exc = context.value
if PY2:
if sys.version_info < (3, 5):
assert exc.output == "outerr"
else:
assert exc.output == "out"

View file

@ -53,8 +53,9 @@ def test_manual_upgrade(session_app_data, caplog, mocker, for_py_version):
assert "upgrade pip" in caplog.text
assert "upgraded pip" in caplog.text
assert " new entries found:\n\tNewVersion" in caplog.text
assert " no new versions found" in caplog.text
assert " new entries found:\n" in caplog.text
assert "\tNewVersion(" in caplog.text
packages = defaultdict(list)
for i in do_update_mock.call_args_list:
packages[i[1]["distribution"]].append(i[1]["for_py_version"])

View file

@ -14,7 +14,7 @@ envlist =
docs
isolated_build = true
skip_missing_interpreters = true
minversion = 3.14.0
minversion = 3.14
[testenv]
description = run tests with {basepython}
@ -33,7 +33,7 @@ setenv =
PYTHONIOENCODING = utf-8
_COVERAGE_SRC = {envsitepackagesdir}/virtualenv
{py34,py27,pypy, upgrade}: PYTHONWARNINGS = ignore:DEPRECATION::pip._internal.cli.base_command
{pypy,py27}: PYTEST_XDIST = 0
{py34,pypy,py27}: PYTEST_XDIST = 0
extras =
testing
commands =
@ -44,7 +44,9 @@ commands =
python -m coverage combine
python -m coverage report --skip-covered --show-missing
python -m coverage xml -o {toxworkdir}/coverage.{envname}.xml
python -m coverage html -d {envtmpdir}/htmlcov
python -m coverage html -d {envtmpdir}/htmlcov \
!py34: --show-contexts \
--title virtualenv-{envname}-coverage
install_command = python -m pip install {opts} {packages} --disable-pip-version-check
[testenv:fix_lint]