Commit 6def51b2 authored by Pierre-Yves David's avatar Pierre-Yves David
Browse files

merge with stable

......@@ -26,3 +26,7 @@ f9cef1264750daeb4e910ed0c8797bf32dcd0505 logilab-mtconverter-debian-version-0.8.
6beee91b01735bb559fff3dad6fca7cb4d91db73 logilab-mtconverter-debian-version-0.8.1-1
4afab0a7475582cf9e41fd0ccbcdcbc757ceca8f logilab-mtconverter-version-0.8.2
373765d880b96cc7fcdc2965174988dbcf089be0 logilab-mtconverter-debian-version-0.8.2-1
e022a32d4858924530bf6a5f4fece5f9aeb5673d logilab-mtconverter-version-0.8.3
da18bbb68bc9d24a979a09204d1f6805eebcaf90 logilab-mtconverter-debian-version-0.8.3-1
c0038265e1bb93c9b105472fad8816ec85f36393 logilab-mtconverter-version-0.8.4
6ea26e5351240c8d11815352a092c960cbd229a1 logilab-mtconverter-debian-version-0.8.4-1
Change log for mtconverter
==========================
2012-03-20 -- 0.8.3
* close #90451: fix unit tests
* close #81707: make python3 package available in sid
* close #89394: Use subprocess instead of os.popen4
2010-07-27 -- 0.8.1
* fix #37143: /> tags break the parse process
......
# copyright 2006-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
# copyright 2006-2012 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
#
# This file is part of logilab-mtconverter.
......@@ -21,7 +21,7 @@ modname = "mtconverter"
distname = "logilab-mtconverter"
subpackage_of = 'logilab'
numversion = (0, 8, 2)
numversion = (0, 8, 4)
version = '.'.join([str(num) for num in numversion])
license = 'LGPL'
......
Source: logilab-mtconverter
Section: python
Priority: optional
Maintainer: Logilab S.A. <contact@logilab.fr>
Uploaders: Sylvain Thenault <sylvain.thenault@logilab.fr>,
Aurélien Campéas <aurelien.campeas@logilab.fr>
Build-Depends: debhelper (>= 7.0.50~), python-all, python3-all
#, python-logilab-common, python-lxml, python-imaging, poppler-utils
Standards-Version: 3.9.2
Homepage: http://www.logilab.org/project/logilab-mtconverter
Vcs-Hg: http://hg.logilab.org/logilab/mtconverter
Vcs-Browser: http://hg.logilab.org/logilab/mtconverter
Package: python-logilab-mtconverter
Architecture: all
Depends: ${python:Depends}, ${misc:Depends}
Suggests: python-imaging, python-pygments, poppler-utils, lynx, python-chardet, python-lxml
Description: library to convert from a MIME type to another
This package originally a backport of Zope's PortalTransforms tool with
all Zope's internal removed (e.g. most of the code).
Package: python3-logilab-mtconverter
Architecture: all
Depends: ${python3:Depends}, ${misc:Depends}
Suggests: python3-imaging, python3-pygments, poppler-utils, lynx, python3-chardet
Description: library to convert from a MIME type to another
This package originally a backport of Zope's PortalTransforms tool with
all Zope's internal removed (e.g. most of the code).
#!/usr/bin/make -f
# -*- makefile -*-
#
# Copyright (c) 2003-2011 LOGILAB S.A. (Paris, FRANCE).
# http://www.logilab.fr/ -- mailto:contact@logilab.fr
# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1
include /usr/share/python/python.mk
PYLIB:=$(call py_libdir,$(shell pyversions -d))
PACKAGE:=$(call py_pkgname,python-logilab-mtconverter,python)
PYLIB3:=$(call py_libdir,python3.)
PACKAGE3:=$(call py_pkgname,python-logilab-mtconverter,python3.)
%:
dh $@ --with python2,python3
override_dh_auto_install:
NO_SETUPTOOLS=1 python setup.py -q install --no-compile \
--root=$(CURDIR)/debian/$(PACKAGE)/ \
${py_setup_install_args}
NO_SETUPTOOLS=1 python3 setup.py -q install --no-compile \
--root=$(CURDIR)/debian/$(PACKAGE3)/ \
${py_setup_install_args}
# remove sub-package __init__ file
rm $(CURDIR)/debian/$(PACKAGE)/$(PYLIB)/logilab/__init__.py
rm $(CURDIR)/debian/$(PACKAGE3)/$(PYLIB3)/logilab/__init__.py
# remove test directory
rm -r $(CURDIR)/debian/$(PACKAGE)/$(PYLIB)/logilab/mtconverter/test
rm -r $(CURDIR)/debian/$(PACKAGE3)/$(PYLIB3)/logilab/mtconverter/test
override_dh_auto_test:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
# PYTHON 2.X + PYTHON 3.2
endif
override_dh_installdocs:
dh_installchangelogs -A -i ChangeLog
dh_installdocs -A -i README*
logilab-mtconverter (0.8.4-1) unstable; urgency=low
* new upstream release
-- Sylvain Thénault <sylvain.thenault@logilab.fr> Thu, 20 Sep 2012 09:33:02 +0200
logilab-mtconverter (0.8.3-1) unstable; urgency=low
* new upstream release
-- David Douard <david.douard@logilab.fr> Tue, 20 Mar 2012 12:16:15 +0100
logilab-mtconverter (0.8.2-1) unstable; urgency=low
* new upstream release
......
\documentclass{letter}
\begin{document}
\thispagestyle{empty}
hello
\end{document}
......@@ -18,12 +18,14 @@
from logilab.common.testlib import TestCase, unittest_main
import urllib
import re
import os.path as osp
from logilab.mtconverter import TransformData, TransformError
from logilab.mtconverter.transforms import text_to_text
from logilab.mtconverter.transform import Transform, TransformsChain
from logilab.mtconverter.engine import TransformEngine
DATAPATH = osp.dirname(__file__)
class HtmlToText(Transform):
inputs = ('text/html',)
......@@ -91,7 +93,7 @@ def html_data():
class EngineTC(TestCase):
def setUp(self):
self.engine = TransformEngine()
def register(self):
#A default set of transforms to prove the interfaces work
self.engine.add_transform(HtmlToText())
......@@ -109,37 +111,37 @@ class EngineTC(TestCase):
def test_has_input(self):
self.register()
self.failUnless(self.engine.has_input('text/html'))
self.failUnless(self.engine.has_input('text/plain'))
self.failUnless(self.engine.has_input('text/whatever'))
self.failIf(self.engine.has_input('application/octet-stream'))
self.assertTrue(self.engine.has_input('text/html'))
self.assertTrue(self.engine.has_input('text/plain'))
self.assertTrue(self.engine.has_input('text/whatever'))
self.assertFalse(self.engine.has_input('application/octet-stream'))
def test_convert(self):
self.register()
self.engine.add_transform(text_to_text())
data = TransformData("This is a test", 'text/x-diff', 'ascii')
out = self.engine.convert(data, 'text/plain')
self.failUnlessEqual(out.data, "This is a test")
self.failUnlessEqual(out.mimetype, 'text/plain')
self.failUnlessEqual(out.encoding, 'ascii')
self.assertEqual(out.data, "This is a test")
self.assertEqual(out.mimetype, 'text/plain')
self.assertEqual(out.encoding, 'ascii')
# html_to_text transform should take priority over text_to_text
data = self.engine.convert(html_data(), "text/plain")
self.failUnlessEqual(data.data, "foo")
self.failUnlessEqual(data.mimetype, 'text/plain')
self.failUnlessEqual(data.encoding, 'ascii')
self.assertEqual(data.data, "foo")
self.assertEqual(data.mimetype, 'text/plain')
self.assertEqual(data.encoding, 'ascii')
self.engine.remove_transform('HtmlToText')
self.engine.remove_transform('FooToBar')
self.engine.add_transform(HtmlToTextWithEncoding())
data = self.engine.convert(html_data(), "text/plain")
self.failUnlessEqual(data.mimetype, 'text/plain')
self.failUnlessEqual(data.encoding, 'utf8')
self.assertEqual(data.mimetype, 'text/plain')
self.assertEqual(data.encoding, 'utf8')
self.engine.add_transform(FooToBar())
data = self.engine.convert(html_data(), 'text/bar')
self.failUnlessEqual(data.data, "<b>bar</b>")
self.assertEqual(data.data, "<b>bar</b>")
def test_chain(self):
#self.register()
......@@ -148,25 +150,25 @@ class EngineTC(TestCase):
hb.append(FooToBar())
self.engine.add_transform(hb)
cache = self.engine.convert(html_data(), 'text/bar')
self.failUnlessEqual(cache.data, "bar")
self.assertEqual(cache.data, "bar")
def test_same(self):
data = TransformData("This is a test", 'text/plain', 'ascii')
out = self.engine.convert(data, 'text/plain')
self.failUnlessEqual(out.data, "This is a test")
self.failUnlessEqual(out.mimetype, 'text/plain')
self.failUnlessEqual(out.encoding, 'ascii')
self.assertEqual(out.data, "This is a test")
self.assertEqual(out.mimetype, 'text/plain')
self.assertEqual(out.encoding, 'ascii')
self.engine.add_transform(HtmlIdTransform())
out = self.engine.convert(html_data(), 'text/html')
self.failUnlessEqual(out.data, "<b>foo</b> transformed")
self.failUnlessEqual(out.mimetype, 'text/html')
self.failUnlessEqual(out.encoding, 'ascii')
self.assertEqual(out.data, "<b>foo</b> transformed")
self.assertEqual(out.mimetype, 'text/html')
self.assertEqual(out.encoding, 'ascii')
def test_convert_compressed(self):
self.register()
data = TransformData(open('data.txt.gz', 'rb').read(), 'text/plain', 'gzip')
data = TransformData(open(osp.join(DATAPATH, 'data.txt.gz'), 'rb').read(), 'text/plain', 'gzip')
self.assertRaises(TransformError, self.engine.convert, data, 'text/plain')
self.engine.add_transform(text_to_text())
self.assertRaises(TransformError, self.engine.convert, data, 'text/plain')
......
......@@ -27,28 +27,35 @@ register_base_transforms(ENGINE)
register_pil_transforms(ENGINE)
import logilab.mtconverter as mtc
import os
import os.path as osp
DATAPATH = osp.join(osp.split(mtc.__file__)[0], 'test')
import subprocess
DATAPATH = osp.dirname(__file__)
class MiscTransformsTC(TestCase):
def test_html_to_text(self):
data = TransformData(u'<b>yo (zou ;)</b>', 'text/html', 'utf8')
converted = ENGINE.convert(data, 'text/plain').decode().strip()
self.assertEquals(converted, u'**yo (zou ;)**')
self.assertEqual(converted, u'**yo (zou ;)**')
# will trigger guess_encoding, check non-utf8 encoding
data = TransformData(u'<b>yo (zou ;)</b>'.encode('latin1'), 'text/html')
data = TransformData(u'<p>yo <br/>zogzog </p>', 'text/html', 'utf8')
converted = ENGINE.convert(data, 'text/plain').decode().strip()
self.assertEquals(converted, u'**yo (zou ;)**')
self.assertEqual(converted, u'yo\n\nzogzog')
def test_html_to_text_noenc(self):
self.skipTest('Encoding detection with chardet does not work')
# will trigger guess_encoding, check non-utf8 encoding
data = TransformData(u"<b>yo (l'tat l'oeuf)</b>".encode('latin1'), 'text/html')
self.assertIn(data.encoding, ('latin1', 'windows-1252'))
data.check_encoding()
data = TransformData(u'<p>yo <br/>zogzog </p>', 'text/html', 'utf8')
converted = ENGINE.convert(data, 'text/plain').decode().strip()
self.assertEquals(converted, u'yo\n\nzogzog')
self.assertEqual(converted, u'**yo (zou ;)**')
def test_xml_to_text(self):
data = TransformData(u'<root><b>yo (zou ;)</b>a<tag/>b<root>', 'application/xml', 'utf8')
converted = ENGINE.convert(data, 'text/plain').decode().strip()
self.assertEquals(converted, u'yo (zou ;) a b')
self.assertEqual(converted, u'yo (zou ;) a b')
def test_pgpsignature_to_text(self):
......@@ -62,242 +69,37 @@ r2MAoIO1DSsuM23SzgmqubGJEZuSRWhR
"""
data = TransformData(_data, 'application/pgp-signature')
converted = ENGINE.convert(data, 'text/plain').decode()
self.assertTextEquals(converted, _data)
self.assertMultiLineEqual(converted, _data)
def test_odt_to_text(self):
data = TransformData(open(osp.join(DATAPATH, 'hello.odt')),
'application/vnd.oasis.opendocument.text', 'utf8')
converted = ENGINE.convert(data, 'text/plain').decode().strip()
self.assertEquals(converted, u'Hello ! OpenOffice.org/2.4$Unix OpenOffice.org_project/680m17$Build-9310 Hello quoi de neuf doc ? bonjour 2008-07-08T16:19:35 2009-01-09T14:44:54 mot-clef 1 PT37S')
self.assertEqual(converted, u'Hello ! OpenOffice.org/2.4$Unix OpenOffice.org_project/680m17$Build-9310 Hello quoi de neuf doc ? bonjour 2008-07-08T16:19:35 2009-01-09T14:44:54 mot-clef 1 PT37S')
# ZipFile will complain that
# TypeError: file() argument 1 must be (encoded string without NULL bytes), not str
# if given a plain str ... we shielded us from that.
data = TransformData(open(osp.join(DATAPATH, 'hello.odt')).read(),
'application/vnd.oasis.opendocument.text', 'utf8')
converted = ENGINE.convert(data, 'text/plain').decode().strip()
self.assertEquals(converted, u'Hello ! OpenOffice.org/2.4$Unix OpenOffice.org_project/680m17$Build-9310 Hello quoi de neuf doc ? bonjour 2008-07-08T16:19:35 2009-01-09T14:44:54 mot-clef 1 PT37S')
if __name__ == '__main__':
unittest_main()
## from utils import input_file_path, output_file_path, normalize_html,\
## load, matching_inputs
## from logilab.mtconverter import MissingBinary
## from logilab.mtconverter.transforms.piltransforms import image_to_gif
## from logilab.mtconverter.transforms.piltransforms import image_to_png
## from logilab.mtconverter.transforms.piltransforms import image_to_jpeg
## from logilab.mtconverter.transforms.piltransforms import image_to_bmp
## from logilab.mtconverter.transforms.piltransforms import image_to_tiff
## from logilab.mtconverter.transforms.piltransforms import image_to_ppm
## from logilab.mtconverter.transforms.piltransforms import image_to_pcx
## from os.path import exists
## import sys
## # we have to set locale because lynx output is locale sensitive !
## os.environ['LC_ALL'] = 'C'
## class TransformTest(TestCase):
## def do_convert(self, filename=None):
## if filename is None and exists(self.output + '.nofilename'):
## output = self.output + '.nofilename'
## else:
## output = self.output
## input = open(self.input)
## orig = input.read()
## input.close()
## data = datastream(self.transform.name())
## res_data = self.transform.convert(orig, data, filename=filename)
## self.assert_(idatastream.isImplementedBy(res_data))
## got = res_data.getData()
## try:
## output = open(output)
## except IOError:
## import sys
## print >>sys.stderr, 'No output file found.'
## print >>sys.stderr, 'File %s created, check it !' % self.output
## output = open(output, 'w')
## output.write(got)
## output.close()
## self.assert_(0)
## expected = output.read()
## if self.normalize is not None:
## expected = self.normalize(expected)
## got = self.normalize(got)
## output.close()
## self.assertEquals(got, expected,
## '[%s]\n\n!=\n\n[%s]\n\nIN %s(%s)' % (
## got, expected, self.transform.name(), self.input))
## self.assertEquals(self.subobjects, len(res_data.getSubObjects()),
## '%s\n\n!=\n\n%s\n\nIN %s(%s)' % (
## self.subobjects, len(res_data.getSubObjects()), self.transform.name(), self.input))
## def testSame(self):
## self.do_convert(filename=self.input)
## def testSameNoFilename(self):
## self.do_convert()
## def __repr__(self):
## return self.transform.name()
self.assertEqual(converted, u'Hello ! OpenOffice.org/2.4$Unix OpenOffice.org_project/680m17$Build-9310 Hello quoi de neuf doc ? bonjour 2008-07-08T16:19:35 2009-01-09T14:44:54 mot-clef 1 PT37S')
## class PILTransformsTest(TestCase):
## def afterSetUp(self):
## ATSiteTestCase.afterSetUp(self)
## self.pt = self.portal.portal_transforms
## def test_image_to_bmp(self):
## self.pt.registerTransform(image_to_bmp())
## imgFile = open(input_file_path('logo.jpg'), 'rb')
## data = imgFile.read()
## self.failUnlessEqual(self.portal.mimetypes_registry.classify(data),'image/jpeg')
## data = self.pt.convertTo(target_mimetype='image/x-ms-bmp',orig=data)
## self.failUnlessEqual(data.getMetadata()['mimetype'], 'image/x-ms-bmp')
## def test_image_to_gif(self):
## self.pt.registerTransform(image_to_gif())
## imgFile = open(input_file_path('logo.png'), 'rb')
## data = imgFile.read()
## self.failUnlessEqual(self.portal.mimetypes_registry.classify(data),'image/png')
## data = self.pt.convertTo(target_mimetype='image/gif',orig=data)
## self.failUnlessEqual(data.getMetadata()['mimetype'], 'image/gif')
## def test_image_to_jpeg(self):
## self.pt.registerTransform(image_to_jpeg())
## imgFile = open(input_file_path('logo.gif'), 'rb')
## data = imgFile.read()
## self.failUnlessEqual(self.portal.mimetypes_registry.classify(data),'image/gif')
## data = self.pt.convertTo(target_mimetype='image/jpeg',orig=data)
## self.failUnlessEqual(data.getMetadata()['mimetype'], 'image/jpeg')
## def test_image_to_png(self):
## self.pt.registerTransform(image_to_png())
## imgFile = open(input_file_path('logo.jpg'), 'rb')
## data = imgFile.read()
## self.failUnlessEqual(self.portal.mimetypes_registry.classify(data),'image/jpeg')
## data = self.pt.convertTo(target_mimetype='image/png',orig=data)
## self.failUnlessEqual(data.getMetadata()['mimetype'], 'image/png')
## def test_image_to_pcx(self):
## self.pt.registerTransform(image_to_pcx())
## imgFile = open(input_file_path('logo.gif'), 'rb')
## data = imgFile.read()
## self.failUnlessEqual(self.portal.mimetypes_registry.classify(data),'image/gif')
## data = self.pt.convertTo(target_mimetype='image/pcx',orig=data)
## self.failUnlessEqual(data.getMetadata()['mimetype'], 'image/pcx')
## def test_image_to_ppm(self):
## self.pt.registerTransform(image_to_ppm())
## imgFile = open(input_file_path('logo.png'), 'rb')
## data = imgFile.read()
## self.failUnlessEqual(self.portal.mimetypes_registry.classify(data),'image/png')
## data = self.pt.convertTo(target_mimetype='image/x-portable-pixmap',orig=data)
## self.failUnlessEqual(data.getMetadata()['mimetype'], 'image/x-portable-pixmap')
## def test_image_to_tiff(self):
## self.pt.registerTransform(image_to_tiff())
## imgFile = open(input_file_path('logo.jpg'), 'rb')
## data = imgFile.read()
## self.failUnlessEqual(self.portal.mimetypes_registry.classify(data),'image/jpeg')
## data = self.pt.convertTo(target_mimetype='image/tiff',orig=data)
## self.failUnlessEqual(data.getMetadata()['mimetype'], 'image/tiff')
## TRANSFORMS_TESTINFO = (
## ('Products.PortalTransforms.transforms.pdf_to_html',
## "demo1.pdf", "demo1.html", None, 0
## ),
## ('Products.PortalTransforms.transforms.word_to_html',
## "test.doc", "test_word.html", normalize_html, 0
## ),
## ('Products.PortalTransforms.transforms.lynx_dump',
## "test_lynx.html", "test_lynx.txt", None, 0
## ),
## ('Products.PortalTransforms.transforms.html_to_text',
## "test_lynx.html", "test_html_to_text.txt", None, 0
## ),
## ('Products.PortalTransforms.transforms.identity',
## "rest1.rst", "rest1.rst", None, 0
## ),
## ('Products.PortalTransforms.transforms.text_to_html',
## "rest1.rst", "rest1.html", None, 0
## ),
## ('Products.PortalTransforms.transforms.safe_html',
## "test_safehtml.html", "test_safe.html", None, 0
## ),
## ('Products.PortalTransforms.transforms.image_to_bmp',
## "logo.jpg", "logo.bmp", None, 0
## ),
## ('Products.PortalTransforms.transforms.image_to_gif',
## "logo.bmp", "logo.gif", None, 0
## ),
## ('Products.PortalTransforms.transforms.image_to_jpeg',
## "logo.gif", "logo.jpg", None, 0
## ),
## ('Products.PortalTransforms.transforms.image_to_png',
## "logo.bmp", "logo.png", None, 0
## ),
## ('Products.PortalTransforms.transforms.image_to_ppm',
## "logo.gif", "logo.ppm", None, 0
## ),
## ('Products.PortalTransforms.transforms.image_to_tiff',
## "logo.png", "logo.tiff", None, 0
## ),
## ('Products.PortalTransforms.transforms.image_to_pcx',
## "logo.png", "logo.pcx", None, 0
## ),
## )
## def initialise(transform, normalize, pattern):
## global TRANSFORMS_TESTINFO
## for fname in matching_inputs(pattern):
## outname = '%s.out' % fname.split('.')[0]
## #print transform, fname, outname
## TRANSFORMS_TESTINFO += ((transform, fname, outname, normalize, 0),)
## # ReST test cases
## initialise('Products.PortalTransforms.transforms.rest', normalize_html, "rest*.rst")
## # Python test cases
## initialise('Products.PortalTransforms.transforms.python', normalize_html, "*.py")
## # FIXME missing tests for image_to_html, st
## TR_NAMES = None
## # generate tests classes from test info
## for _transform, tr_input, tr_output, _normalize, _subobjects in TRANSFORMS_TESTINFO:
## # load transform if necessary
## if type(_transform) is type(''):
## try:
## _transform = load(_transform).register()
## except MissingBinary:
## # we are not interessted in tests with missing binaries
## continue
## except:
## import traceback
## traceback.print_exc()
## continue
## if TR_NAMES is not None and not _transform.name() in TR_NAMES:
## print 'skip test for', _transform.name()
## continue
## class TransformTestSubclass(TransformTest):
## input = input_file_path(tr_input)
## output = output_file_path(tr_output)
## transform = _transform
## normalize = lambda x, y: _normalize(y)
## subobjects = _subobjects
def test_pdf_to_text(self):
subprocess.check_call(['pdflatex', 'hello'], cwd=osp.abspath(DATAPATH), stdout=open(os.devnull, 'w'))
data = TransformData(open(osp.join(DATAPATH, 'hello.pdf')).read(),
'application/pdf', 'utf8')
converted = ENGINE.convert(data, 'text/plain').decode().strip()
self.assertEqual(converted, u'hello')
## tests.append(TransformTestSubclass)
def tearDown(self):
for ext in ('pdf', 'aux', 'log'):
try:
os.unlink(osp.join(DATAPATH, 'hello.' + ext))
except OSError:
pass
## tests.append(PILTransformsTest)
if __name__ == '__main__':
unittest_main()
......@@ -41,26 +41,26 @@ class HtmlEscapeTC(TestCase):
('d"h"', 'd&quot;h&quot;'),
("h'", 'h&#39;'),
]:
yield self.assertEquals, xml_escape(data), expected
yield self.assertEqual, xml_escape(data), expected
def test_escape_special_chars(self):
for car, trcar in SPECIAL_CHARS.items():
yield self.assertEquals, xml_escape(car), trcar
yield self.assertEqual, xml_escape(car), trcar
for carnum in xrange(32):
car = chr(carnum)
if car in SPECIAL_CHARS:
continue
yield self.assertEquals, xml_escape(car), ' '
yield self.assertEquals, xml_escape(u'é'), u'é'
yield self.assertEqual, xml_escape(car), ' '
yield self.assertEqual, xml_escape(u'é'), u'é'
def test_escape_special_chars_unicode(self):
for car, trcar in SPECIAL_CHARS.items():
yield self.assertEquals, xml_escape(unicode(car)), trcar
yield self.assertEqual, xml_escape(unicode(car)), trcar
for carnum in xrange(32):
car = chr(carnum)
if car in SPECIAL_CHARS:
continue
yield self.assertEquals, xml_escape(unicode(car)), ' '
yield self.assertEqual, xml_escape(unicode(car)), ' '
def test_html_unescape(self):
for data, expected in [('toto', 'toto'),
......@@ -70,23 +70,23 @@ class HtmlEscapeTC(TestCase):
('h&#39;', "h'"),
('x &equiv; y', u"x \u2261 y"),
]:
yield self.assertEquals, html_unescape(data), expected
yield self.assertEqual, html_unescape(data), expected
class GuessEncodingTC(TestCase):
def test_emacs_style_declaration(self):
data = '''# -*- coding: latin1 -*-'''
self.assertEquals(guess_encoding(data), 'latin1')
self.assertEqual(guess_encoding(data), 'latin1')
def test_emacs_style_declaration_stringIO(self):
data = '''# -*- coding: latin1 -*-'''
self.assertEquals(guess_encoding(StringIO(data)), 'latin1')
self.assertEqual(guess_encoding(StringIO(data)), 'latin1')
def test_xml_style_declaration(self):
data = '''<?xml version="1.0" encoding="latin1"?>
<root/>'''
self.assertEquals(guess_encoding(data), 'latin1')
self.assertEqual(guess_encoding(data), 'latin1')
def test_html_style_declaration(self):