Revision: 10e773e95a87
Branch: default
Author: Winston W <
wins...@stratolab.com>
Date: Mon Feb 4 16:00:22 2013
Log: Add AttributedTextDecoderTests and test that two newlines becomes
one in output.
http://code.google.com/p/pyglet/source/detail?r=10e773e95a87
Added:
/tests/text/ATTRIBUTED_TEXT_DECODER.py
Modified:
/pyglet/text/formats/attributed.py
/tests/plan.txt
/tests/text/MULTILINE_WRAP.py
=======================================
--- /dev/null
+++ /tests/text/ATTRIBUTED_TEXT_DECODER.py Mon Feb 4 16:00:22 2013
@@ -0,0 +1,17 @@
+import unittest
+
+from pyglet.text.formats.attributed import AttributedTextDecoder
+
+class AttributedTextDecoderTests(unittest.TestCase):
+ __noninteractive = True
+ def testOneNewlineBecomesSpace(self):
+ doc = AttributedTextDecoder().decode('one\ntwo')
+ self.assertEqual(u'one two', doc.text)
+
+ def testTwoNewlinesBecomesParagraph(self):
+ from pyglet.text.formats.attributed import AttributedTextDecoder
+ doc = AttributedTextDecoder().decode('one\n\ntwo')
+ self.assertEqual(u'one\ntwo', doc.text)
+
+if __name__ == '__main__':
+ unittest.main()
=======================================
--- /pyglet/text/formats/attributed.py Sun Feb 1 20:38:24 2009
+++ /pyglet/text/formats/attributed.py Mon Feb 4 16:00:22 2013
@@ -86,7 +86,7 @@
self.append('\n')
trailing_newline = True
elif group == 'nl_para':
- self.append(m.group('nl_para'))
+ self.append(m.group('nl_para')[1:]) # ignore the first \n
trailing_newline = True
elif group == 'attr':
try:
=======================================
--- /tests/plan.txt Wed Nov 7 06:27:00 2012
+++ /tests/plan.txt Mon Feb 4 16:00:22 2013
@@ -228,3 +228,4 @@
text.HTML GENERIC
text.HTML_IMAGE GENERIC
text.MULTILINE_WRAP GENERIC
+ text.ATTRIBUTED_TEXT_DECODER GENERIC
=======================================
--- /tests/text/MULTILINE_WRAP.py Thu Jun 21 23:08:42 2012
+++ /tests/text/MULTILINE_WRAP.py Mon Feb 4 16:00:22 2013
@@ -112,5 +112,6 @@
self.window.set_visible()
app.run()
+
if __name__ == '__main__':
unittest.main()