Skip to content

Commit

Permalink
Support for tox >= 3.8.0
Browse files Browse the repository at this point in the history
* Added simple test case for plugin invocation
* Raised version to 0.2.1
* Integrated switches for <3.8 and >=3.8 handling
* Fixes #6
  • Loading branch information
danwos committed May 9, 2019
1 parent 3ecc803 commit 1a0cab2
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 21 deletions.
7 changes: 6 additions & 1 deletion docs/changelog.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
Changelog
=========

0.2.1
-----

* Bugfix: Support for tox >= 3.8.0 (`#3 <https://github.com/useblocks/tox-envreport/issues/3>`_)

0.2.0
-----

Expand All @@ -16,4 +21,4 @@ Changelog
0.1.0
-----

* Initial version
* Initial version
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@
# built documents.
#
# The short X.Y version.
version = '0.1.0'
version = '0.2.1'
# The full version, including alpha/beta/rc tags.
release = '0.1.0'
release = '0.2.1'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def read(fname):
description='A tox-plugin to document the setup of used virtual '
'environments.',
long_description=read('README.rst'),
version='0.2.0',
version='0.2.1',
author='team useblocks',
author_email='team@useblocks.com',
maintainer='team useblocks',
Expand Down
2 changes: 2 additions & 0 deletions test-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pytest >= 3.0.0, <5
packaging
1 change: 1 addition & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from tox._pytestplugin import initproj, cmd, pytest_configure, pytest_addoption # noqa
25 changes: 19 additions & 6 deletions tests/test_tox_envreport.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,22 @@
# -*- coding: utf-8 -*-


def test_dummy():
"""
TODO think about how to test this properly
TODO check tox own tests to see how to do this (use of _pytestplugin)
TODO (also check if someone did this already)
"""
def test_dummy(cmd, initproj, monkeypatch):
monkeypatch.delenv(str("TOXENV"), raising=False)

path = initproj(
'envreport_123',
filedefs={
'tox.ini': """
[tox]
envlist = a
[testenv]
deps=tox-envreport
commands=echo "yehaaa"
"""
})

assert path

result = cmd('all')
assert result
13 changes: 8 additions & 5 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
# For more information about tox, see https://tox.readthedocs.io/en/latest/
[tox]
envlist = py27,py34,py35,py36,flake8

[flake8]
exclude = .tox,.cache,docs
envlist = py{27,35,36}-tox{37,38},flake8

[testenv]
deps = pytest
deps = -rtest-requirements.txt
tox37: tox>=3.7,<3.8
tox38: tox>=3.8,<3.9

commands = pytest {posargs:tests}

[flake8]
exclude = .tox,.cache,docs

[testenv:flake8]
skip_install = true
deps = flake8
Expand Down
24 changes: 18 additions & 6 deletions tox_envreport/plugin.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# -*- coding: utf-8 -*-
import logging
import os

from packaging import version
import pluggy
import json
import tox


hookimpl = pluggy.HookimplMarker("tox")
log = logging.getLogger('envreport')
Expand All @@ -23,7 +25,11 @@ def tox_runtest_post(venv):
# Collect paths from current configuration
# ----------------------------------------
venv_path = venv.path.strpath
tox_workdir = venv.session.config.toxworkdir.strpath

if version.parse(tox.__version__) < version.parse('3.8.0'): # tox < 3.8.0
tox_workdir = venv.session.config.toxworkdir.strpath
else:
tox_workdir = venv.path
tox_report_path = os.path.join(tox_workdir, "tox-report.json")
venv_report_path = os.path.join(venv_path, "env-report.json")

Expand Down Expand Up @@ -68,10 +74,16 @@ def collect_data(current_venv):
"name": current_venv.name,
"path": current_venv.path.strpath,
}
data[current_venv.name].update(current_venv.session.resultlog.dict)
if version.parse(tox.__version__) < version.parse('3.8.0'): # tox < 3.8.0
data[current_venv.name].update(current_venv.session.resultlog.dict)
else:
data[current_venv.name].update(current_venv.env_log.reportlog.dict)

data[current_venv.name].pop("testenvs", None)
data[current_venv.name].update(
current_venv.session.resultlog.dict["testenvs"][current_venv.name])

if version.parse(tox.__version__) < version.parse('3.8.0'): # tox < 3.8.0
data[current_venv.name].update(
current_venv.session.resultlog.dict["testenvs"][current_venv.name])
else:
data[current_venv.name].update(
current_venv.env_log.reportlog.dict["testenvs"][current_venv.name])
return data

0 comments on commit 1a0cab2

Please sign in to comment.