Skip to content
This repository has been archived by the owner on Nov 19, 2024. It is now read-only.

Make tox-pipenv support version of tox >= 3.8 #66

Merged
merged 7 commits into from
Apr 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ python:
- "2.7"
- "3.5"
- "3.6"
- "3.7"


env:
Expand All @@ -11,6 +12,7 @@ env:
- TOX_VERSION="tox>=3.2,<3.3"
- TOX_VERSION="tox>=3.3,<3.4"
- TOX_VERSION="tox>=3.4,<3.5"
- TOX_VERSION="tox>=3.8,<3.14

install:
- pip install ${TOX_VERSION} tox-travis codecov
Expand Down
6 changes: 4 additions & 2 deletions test/conftest.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import pytest
import py
import subprocess
import os

from _pytest.tmpdir import tmpdir

Expand All @@ -12,7 +13,7 @@ def __init__(self, tmpdir):
"""
Fake tox config with static values
"""
toxinidir = "~/foo"
toxinidir = os.curdir


class MockEnvironmentConfig(object):
Expand Down Expand Up @@ -70,7 +71,8 @@ def popen(self, *args, **kwargs):

@pytest.fixture
def venv(tmpdir):
return MockVenv(tmpdir)
venv = MockVenv(tmpdir)
return venv


@pytest.fixture
Expand Down
2 changes: 1 addition & 1 deletion tox_pipenv/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "1.9.0"
__version__ = "1.9.1"
22 changes: 14 additions & 8 deletions tox_pipenv/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
import os
import tox
from tox import hookimpl
from tox import reporter
from tox.venv import cleanup_for_venv
import contextlib


Expand All @@ -24,10 +26,9 @@ def _clone_pipfile(venv):
venv.path.ensure(dir=1)

venv_pipfile_path = venv.path.join("Pipfile")
if not root_pipfile_path.exists():
if not os.path.exists(str(root_pipfile_path)):
with open(str(root_pipfile_path), "a"):
os.utime(str(root_pipfile_path), None)

if not venv_pipfile_path.check():
root_pipfile_path.copy(venv_pipfile_path)
return venv_pipfile_path
Expand Down Expand Up @@ -61,7 +62,12 @@ def tox_testenv_create(venv, action):

args.extend(["--python", str(config_interpreter)])

venv.session.make_emptydir(venv.path)
if hasattr(venv.envconfig, 'make_emptydir'):
venv.envconfig.make_emptydir(venv.path)
else:
# tox 3.8.0 removed make_emptydir, See tox #1219
cleanup_for_venv(venv)

basepath = venv.path.dirpath()
basepath.ensure(dir=1)
pipfile_path = _clone_pipfile(venv)
Expand All @@ -86,7 +92,7 @@ def tox_testenv_install_deps(venv, action):
basepath.ensure(dir=1)
pipfile_path = _clone_pipfile(venv)
args = [sys.executable, "-m", "pipenv", "install", "--dev"]
if action.venv.envconfig.pip_pre:
if venv.envconfig.pip_pre:
args.append('--pre')
with wrap_pipenv_environment(venv, pipfile_path):
if deps:
Expand All @@ -105,7 +111,7 @@ def tox_runtest(venv, redirect):
_init_pipenv_environ()
pipfile_path = _clone_pipfile(venv)

action = venv.session.newaction(venv, "runtests")
action = venv.new_action("runtests")

with wrap_pipenv_environment(venv, pipfile_path):
action.setactivity(
Expand Down Expand Up @@ -139,20 +145,20 @@ def tox_runtest(venv, redirect):
)
except tox.exception.InvocationError as err:
if venv.envconfig.ignore_outcome:
venv.session.report.warning(
reporter.warning(
"command failed but result from testenv is ignored\n"
" cmd: %s" % (str(err),)
)
venv.status = "ignored failed command"
continue # keep processing commands

venv.session.report.error(str(err))
reporter.error(str(err))
venv.status = "commands failed"
if not venv.envconfig.ignore_errors:
break # Don't process remaining commands
except KeyboardInterrupt:
venv.status = "keyboardinterrupt"
venv.session.report.error(venv.status)
reporter.error(venv.status)
raise

return True
Expand Down