test_future4.py 1.48 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12
from __future__ import unicode_literals

import unittest
from test import test_support

class TestFuture(unittest.TestCase):
    def assertType(self, obj, typ):
        self.assert_(type(obj) is typ,
            "type(%r) is %r, not %r" % (obj, type(obj), typ))

    def test_unicode_strings(self):
        self.assertType("", unicode)
13
        self.assertType('', unicode)
14
        self.assertType(r"", unicode)
15 16 17 18 19
        self.assertType(r'', unicode)
        self.assertType(""" """, unicode)
        self.assertType(''' ''', unicode)
        self.assertType(r""" """, unicode)
        self.assertType(r''' ''', unicode)
20
        self.assertType(u"", unicode)
21
        self.assertType(u'', unicode)
22
        self.assertType(ur"", unicode)
23 24 25 26 27 28
        self.assertType(ur'', unicode)
        self.assertType(u""" """, unicode)
        self.assertType(u''' ''', unicode)
        self.assertType(ur""" """, unicode)
        self.assertType(ur''' ''', unicode)

29
        self.assertType(b"", str)
30
        self.assertType(b'', str)
31
        self.assertType(br"", str)
32 33 34 35 36 37 38 39 40 41
        self.assertType(br'', str)
        self.assertType(b""" """, str)
        self.assertType(b''' ''', str)
        self.assertType(br""" """, str)
        self.assertType(br''' ''', str)

        self.assertType('' '', unicode)
        self.assertType('' u'', unicode)
        self.assertType(u'' '', unicode)
        self.assertType(u'' u'', unicode)
42 43 44 45 46 47

def test_main():
    test_support.run_unittest(TestFuture)

if __name__ == "__main__":
    test_main()