Disable ANSI codes support by default

Due to ansi2html having a less permissive license, remove it as a dependency.
This commit is contained in:
Dave Hunt 2016-12-19 15:37:32 +00:00
parent 0b8c46cc33
commit f84482bc6a
No known key found for this signature in database
GPG Key ID: 4000D32ABB02F959
5 changed files with 34 additions and 11 deletions

View File

@ -1,6 +1,12 @@
Release Notes
-------------
**1.13.0 (2016-12-19)**
* Disable ANSI codes support by default due to dependency on
`ansi2html <https://pypi.python.org/pypi/ansi2html/>`_ package with less
permissive licensing
**1.12.0 (2016-11-30)**
* Add support for JPG and SVG images

View File

@ -43,6 +43,15 @@ Then run your tests with:
$ pytest --html=report.html
ANSI codes
----------
Note that ANSI code support depends on the
`ansi2html <https://pypi.python.org/pypi/ansi2html/>`_ package. Due to the use
of a less permissive license, this package is not included as a dependency. If
you have this package installed, then ANSI codes will be converted to HTML in
your report.
Creating a self-contained report
----------------------------------

View File

@ -15,7 +15,13 @@ import time
import bisect
import hashlib
from ansi2html import Ansi2HTMLConverter, style
try:
from ansi2html import Ansi2HTMLConverter, style
ANSI = True
except ImportError:
# ansi2html is not installed
ANSI = False
import pytest
from py.xml import html, raw
@ -233,8 +239,9 @@ class HTMLReport(object):
for header, content in report.sections:
log.append(' {0} '.format(header).center(80, '-'))
log.append(html.br())
content = Ansi2HTMLConverter(inline=False).convert(content,
full=False)
if ANSI:
converter = Ansi2HTMLConverter(inline=False)
content = converter.convert(content, full=False)
log.append(raw(content))
if len(log) == 0:
@ -297,12 +304,13 @@ class HTMLReport(object):
if PY3:
self.style_css = self.style_css.decode('utf-8')
ansi_css = [
'\n/******************************',
' * ANSI2HTML STYLES',
' ******************************/\n']
ansi_css.extend([str(r) for r in style.get_styles()])
self.style_css += '\n'.join(ansi_css)
if ANSI:
ansi_css = [
'\n/******************************',
' * ANSI2HTML STYLES',
' ******************************/\n']
ansi_css.extend([str(r) for r in style.get_styles()])
self.style_css += '\n'.join(ansi_css)
css_href = '{0}/{1}'.format('assets', 'style.css')
html_css = html.link(href=css_href, rel='stylesheet',

View File

@ -11,8 +11,7 @@ setup(name='pytest-html',
package_data={'pytest_html': ['resources/*']},
entry_points={'pytest11': ['html = pytest_html.plugin']},
setup_requires=['setuptools_scm'],
install_requires=['ansi2html>=1.1.1',
'pytest>=2.3'],
install_requires=['pytest>=2.3'],
license='Mozilla Public License 2.0 (MPL 2.0)',
keywords='py.test pytest html report',
classifiers=[

View File

@ -9,6 +9,7 @@ envlist = py{26,27,33,34,35,py,py3}-pytest{29,30}, flake8
[testenv]
commands = py.test -v -r a {posargs}
deps =
ansi2html==1.1.1
pytest29: pytest==2.9.2
pytest30: pytest==3.0.4
pytest-xdist