diff --git a/.travis.yml b/.travis.yml index c1393b4..4a87d50 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,54 +1,21 @@ -# https://travis-ci.org/peterbe/premailer - -# This indicates to Travis that we will not use or need sudo -# so that we can benefit from and use the cache->directories -# directive. -sudo: no - -env: PIP_DOWNLOAD_CACHE="pip_cache" -cache: - directories: - - pip_cache - language: python - -before_install: - # twine is necessary so that travis can deploy - - travis_retry pip install twine - - travis_retry pip install tox coveralls - -install: - - travis_retry python setup.py install - -# See https://github.com/travis-ci/travis-ci/issues/4794 -# and https://github.com/audreyr/cookiecutter/pull/540/files -python: 3.5 - +python: 2.7 +sudo: false +os: + - linux + - osx env: - - TOX_ENV=flake8 + - TOX_ENV=lint - TOX_ENV=py26 - TOX_ENV=py27 + - TOX_ENV=pypy + - TOX_ENV=py32 - TOX_ENV=py33 - TOX_ENV=py34 - - TOX_ENV=py35 - - TOX_ENV=pypy + - TOX_ENV=docs + +install: + - pip install tox script: - tox -e $TOX_ENV - -after_success: - # Report coverage results to coveralls.io - - coveralls - -deploy: - provider: pypi - user: peterbe - password: - secure: mdzD1SHDQ84ZK8tVXdF2LuMsws7it/7foompnuNUTQSVaKdjaHpwTYQtmdLUX0Jv54Plx4861GWNf6CD5IVfU7G8R2Ls/5/tQECFG01AspGz23lL1PxUg9tpNm+LPkQtkJzvS3f4i6/mODnKcoaSnhL63JuGaUNa72B1yBaN4hY= - on: - repo: peterbe/premailer - distributions: "sdist bdist_wheel" - -notifications: - email: - on_success: never diff --git a/premailer/premailer.py b/premailer/premailer.py index 293b8d3..e7eb2d8 100644 --- a/premailer/premailer.py +++ b/premailer/premailer.py @@ -462,7 +462,8 @@ def transform(self, pretty_print=True, **kwargs): kwargs.setdefault('method', self.method) kwargs.setdefault('pretty_print', pretty_print) kwargs.setdefault('encoding', 'utf-8') # As Ken Thompson intended - out = etree.tostring(root, **kwargs).decode(kwargs['encoding']) + out_bytes = etree.tostring(root, **kwargs) + out = out_bytes.decode(kwargs['encoding']) if self.method == 'xml': out = _cdata_regex.sub( lambda m: '/**/' % m.group(1), diff --git a/premailer/tests/test_premailer.py b/premailer/tests/test_premailer.py index a7e7442..365fc88 100644 --- a/premailer/tests/test_premailer.py +++ b/premailer/tests/test_premailer.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- from __future__ import absolute_import, unicode_literals import sys import re @@ -2225,6 +2226,23 @@ def test_capture_cssutils_logging(self): p.transform() # it should work eq_(mylog.getvalue(), '') + def test_unicode_crescent_moon_0x1f319(self): + html = ''' + + + + + Dear Skyelar 🌙, + + +''' + p = Premailer(html) + + # Calling transform should not mangle + # the unicode character 🌙 + mojibake = p.transform() + compare_html(mojibake, html) + def test_type_test(self): """test the correct type is returned"""