diff --git a/CHANGES.rst b/CHANGES.rst
index c271b8c0..5ed3b8dd 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -1,6 +1,12 @@
Release Notes
-------------
+**1.13.0 (2016-12-19)**
+
+* Disable ANSI codes support by default due to dependency on
+ `ansi2html `_ package with less
+ permissive licensing
+
**1.12.0 (2016-11-30)**
* Add support for JPG and SVG images
diff --git a/README.rst b/README.rst
index 8f5d343c..43aeaf2e 100644
--- a/README.rst
+++ b/README.rst
@@ -43,6 +43,15 @@ Then run your tests with:
$ pytest --html=report.html
+ANSI codes
+----------
+
+Note that ANSI code support depends on the
+`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
----------------------------------
diff --git a/pytest_html/plugin.py b/pytest_html/plugin.py
index f3b70af3..30d0f3d6 100644
--- a/pytest_html/plugin.py
+++ b/pytest_html/plugin.py
@@ -15,7 +15,13 @@
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 @@ def append_log_html(self, report, additional_html):
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 @@ def _generate_report(self, session):
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',
diff --git a/setup.py b/setup.py
index 126d8722..0d257fb3 100644
--- a/setup.py
+++ b/setup.py
@@ -11,8 +11,7 @@
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=[
diff --git a/tox.ini b/tox.ini
index 4ffc8467..842c8dc9 100644
--- a/tox.ini
+++ b/tox.ini
@@ -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