#! /usr/bin/env python # Author: David Goodger # Contact: goodger@users.sourceforge.net # Revision: $Revision: 3129 $ # Date: $Date: 2005-03-26 17:21:28 +0100 (Sat, 26 Mar 2005) $ # Copyright: This module has been placed in the public domain. """ Tests for misc.py "unicode" directive. """ from __init__ import DocutilsTestSupport def suite(): s = DocutilsTestSupport.ParserTestSuite() s.generateTests(totest) return s totest = {} totest['unicode'] = [ [""" Insert an em-dash (|mdash|), a copyright symbol (|copy|), a non-breaking space (|nbsp|), a backwards-not-equals (|bne|), and a captial omega (|Omega|). .. |mdash| unicode:: 0x02014 .. |copy| unicode:: \\u00A9 .. |nbsp| unicode::   .. |bne| unicode:: U0003D U020E5 .. |Omega| unicode:: U+003A9 """, u"""\ Insert an em-dash ( mdash ), a copyright symbol ( copy ), a non-breaking space ( nbsp ), a backwards-not-equals ( bne ), and a captial omega ( Omega ). \u2014 \u00A9 \u00A0 = \u20e5 \u03a9 """], [""" Bad input: .. |empty| unicode:: .. |empty too| unicode:: .. comment doesn't count as content .. |not hex| unicode:: 0xHEX .. |not all hex| unicode:: UABCX .. unicode:: not in a substitution definition """, """\ Bad input: Error in "unicode" directive: 1 argument(s) required, 0 supplied. unicode:: Substitution definition "empty" empty or invalid. .. |empty| unicode:: Substitution definition "empty too" empty or invalid. .. |empty too| unicode:: .. comment doesn't count as content 0xHEX UABCX Invalid context: the "unicode" directive can only be used within a substitution definition. .. unicode:: not in a substitution definition """], [""" Testing comments and extra text. Copyright |copy| 2003, |BogusMegaCorp (TM)|. .. |copy| unicode:: 0xA9 .. copyright sign .. |BogusMegaCorp (TM)| unicode:: BogusMegaCorp U+2122 .. with trademark sign """, u"""\ Testing comments and extra text. Copyright copy 2003, BogusMegaCorp (TM) . \u00A9 BogusMegaCorp \u2122 """], [""" .. |too big for int| unicode:: 0x111111111111111111 .. |too big for unicode| unicode:: 0x11111111 """, """\ Invalid character code: 0x111111111111111111 ValueError: %s unicode:: 0x111111111111111111 Substitution definition "too big for int" empty or invalid. .. |too big for int| unicode:: 0x111111111111111111 Invalid character code: 0x11111111 %s unicode:: 0x11111111 Substitution definition "too big for unicode" empty or invalid. .. |too big for unicode| unicode:: 0x11111111 """ % ([DocutilsTestSupport.exception_data( 'unichr(int("111111111111111111", 16))')[0], 'code too large (%s)' % DocutilsTestSupport.exception_data( 'unichr(int("111111111111111111", 16))')[0]] [isinstance(DocutilsTestSupport.exception_data( 'unichr(int("111111111111111111", 16))')[0], OverflowError)], DocutilsTestSupport.exception_data('unichr(int("11111111", 16))')[2])] ] if __name__ == '__main__': import unittest unittest.main(defaultTest='suite')