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

Commit

Permalink
Make tox-pipenv support version of tox >= 3.8 (#66)
Browse files Browse the repository at this point in the history
* Changes taken from existing PR by @chiqomar with some adaptations.

* Bump version and testing in Travis to include latest tox

* Fix test failures

* Change handling of missing method in new versions of tox

* Fix envdir missing exists attrib

* Fix local path issues

* Fix flake8 issue
  • Loading branch information
uhurusurfa authored Apr 5, 2020
1 parent 662ddc2 commit 17c4149
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 11 deletions.
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

0 comments on commit 17c4149

Please sign in to comment.