diff options
| author | milde <milde@929543f6-e4f2-0310-98a6-ba3bd3dd1d04> | 2010-03-26 08:37:17 +0000 |
|---|---|---|
| committer | milde <milde@929543f6-e4f2-0310-98a6-ba3bd3dd1d04> | 2010-03-26 08:37:17 +0000 |
| commit | 1459bd400765d19bbdd45e05677f67c40c31fa79 (patch) | |
| tree | bab547d9b8048a28a993296835d0660eb31b0436 /docutils/test/test_nodes.py | |
| parent | 2edb539a4ea6e2df27a9fd5f68665d979ffdb138 (diff) | |
| download | docutils-1459bd400765d19bbdd45e05677f67c40c31fa79.tar.gz | |
Fix [ 2975987 ] repr(Text) failed with long string (Jeffrey C. Jacobs).
The py3k compatibility code introduced a type error that went
unnoticed because there was no test for the trimming of long strings.
git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk@6293 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
Diffstat (limited to 'docutils/test/test_nodes.py')
| -rwxr-xr-x | docutils/test/test_nodes.py | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/docutils/test/test_nodes.py b/docutils/test/test_nodes.py index 9c25eac34..d159db2ab 100755 --- a/docutils/test/test_nodes.py +++ b/docutils/test/test_nodes.py @@ -24,9 +24,15 @@ class TextTests(unittest.TestCase): def setUp(self): self.text = nodes.Text('Line 1.\nLine 2.') self.unicode_text = nodes.Text(u'Möhren') + self.longtext = nodes.Text('Mary had a little lamb whose ' + 'fleece was white as snow and ' + 'everwhere that Mary went the ' + 'lamb was sure to go.') def test_repr(self): self.assertEquals(repr(self.text), r"<#text: 'Line 1.\nLine 2.'>") + self.assertEquals(self.text.shortrepr(), + r"<#text: 'Line 1.\nLine 2.'>") def test_str(self): self.assertEquals(str(self.text), 'Line 1.\nLine 2.') @@ -43,12 +49,18 @@ class TextTests(unittest.TestCase): def test_asciirestriction(self): if sys.version_info < (3,): - self.assertRaises(UnicodeError, nodes.Text, b('hol%s' % chr(224))) - # more specifically: UnicodeDecodeError since py2.3 + self.assertRaises(UnicodeDecodeError, nodes.Text, + b('hol%s' % chr(224))) else: # no bytes at all allowed self.assertRaises(TypeError, nodes.Text, b('hol')) + def test_longrepr(self): + self.assertEquals(repr(self.longtext), r"<#text: 'Mary had a " + r"little lamb whose fleece was white as snow " + r"and everwh ...'>") + self.assertEquals(self.longtext.shortrepr(), + r"<#text: 'Mary had a lit ...'>") class ElementTests(unittest.TestCase): |
