Python test.test_support.have_unicode() Examples
The following are 30
code examples of test.test_support.have_unicode().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
test.test_support
, or try the search function
.
Example #1
Source File: test_isinstance.py From oss-ftp with MIT License | 6 votes |
def test_subclass_tuple(self): # test with a tuple as the second argument classes self.assertEqual(True, issubclass(Child, (Child,))) self.assertEqual(True, issubclass(Child, (Super,))) self.assertEqual(False, issubclass(Super, (Child,))) self.assertEqual(True, issubclass(Super, (Child, Super))) self.assertEqual(False, issubclass(Child, ())) self.assertEqual(True, issubclass(Super, (Child, (Super,)))) self.assertEqual(True, issubclass(NewChild, (NewChild,))) self.assertEqual(True, issubclass(NewChild, (NewSuper,))) self.assertEqual(False, issubclass(NewSuper, (NewChild,))) self.assertEqual(True, issubclass(NewSuper, (NewChild, NewSuper))) self.assertEqual(False, issubclass(NewChild, ())) self.assertEqual(True, issubclass(NewSuper, (NewChild, (NewSuper,)))) self.assertEqual(True, issubclass(int, (long, (float, int)))) if test_support.have_unicode: self.assertEqual(True, issubclass(str, (unicode, (Child, NewChild, basestring))))
Example #2
Source File: test_float.py From ironpython2 with Apache License 2.0 | 6 votes |
def test_float(self): self.assertEqual(float(3.14), 3.14) self.assertEqual(float(314), 314.0) self.assertEqual(float(314L), 314.0) self.assertEqual(float(" 3.14 "), 3.14) self.assertRaises(ValueError, float, " 0x3.1 ") self.assertRaises(ValueError, float, " -0x3.p-1 ") self.assertRaises(ValueError, float, " +0x3.p-1 ") self.assertRaises(ValueError, float, "++3.14") self.assertRaises(ValueError, float, "+-3.14") self.assertRaises(ValueError, float, "-+3.14") self.assertRaises(ValueError, float, "--3.14") # check that we don't accept alternate exponent markers self.assertRaises(ValueError, float, "-1.7d29") self.assertRaises(ValueError, float, "3D-14") if test_support.have_unicode: self.assertEqual(float(unicode(" 3.14 ")), 3.14) self.assertEqual(float(unicode(" \u0663.\u0661\u0664 ",'raw-unicode-escape')), 3.14) # extra long strings should no longer be a problem # (in 2.6, long unicode inputs to float raised ValueError) float('.' + '1'*1000) float(unicode('.' + '1'*1000))
Example #3
Source File: test_tcl.py From ironpython2 with Apache License 2.0 | 6 votes |
def test_getint(self): tcl = self.interp.tk for i in self.get_integers(): result = tcl.getint(' %d ' % i) self.assertEqual(result, i) self.assertIsInstance(result, type(int(result))) if tcl_version >= (8, 5): self.assertEqual(tcl.getint(' {:#o} '.format(i)), i) self.assertEqual(tcl.getint(' %#o ' % i), i) self.assertEqual(tcl.getint(' %#x ' % i), i) if tcl_version < (8, 5): # bignum was added in Tcl 8.5 self.assertRaises(TclError, tcl.getint, str(2**1000)) self.assertEqual(tcl.getint(42), 42) self.assertRaises(TypeError, tcl.getint) self.assertRaises(TypeError, tcl.getint, '42', '10') self.assertRaises(TypeError, tcl.getint, 42.0) self.assertRaises(TclError, tcl.getint, 'a') self.assertRaises((TypeError, ValueError, TclError), tcl.getint, '42\0') if test_support.have_unicode: self.assertEqual(tcl.getint(unicode('42')), 42) self.assertRaises((UnicodeEncodeError, ValueError, TclError), tcl.getint, '42' + unichr(0xd800))
Example #4
Source File: test_float.py From BinderFilter with MIT License | 6 votes |
def test_float(self): self.assertEqual(float(3.14), 3.14) self.assertEqual(float(314), 314.0) self.assertEqual(float(314L), 314.0) self.assertEqual(float(" 3.14 "), 3.14) self.assertRaises(ValueError, float, " 0x3.1 ") self.assertRaises(ValueError, float, " -0x3.p-1 ") self.assertRaises(ValueError, float, " +0x3.p-1 ") self.assertRaises(ValueError, float, "++3.14") self.assertRaises(ValueError, float, "+-3.14") self.assertRaises(ValueError, float, "-+3.14") self.assertRaises(ValueError, float, "--3.14") # check that we don't accept alternate exponent markers self.assertRaises(ValueError, float, "-1.7d29") self.assertRaises(ValueError, float, "3D-14") if test_support.have_unicode: self.assertEqual(float(unicode(" 3.14 ")), 3.14) self.assertEqual(float(unicode(" \u0663.\u0661\u0664 ",'raw-unicode-escape')), 3.14) # extra long strings should no longer be a problem # (in 2.6, long unicode inputs to float raised ValueError) float('.' + '1'*1000) float(unicode('.' + '1'*1000))
Example #5
Source File: test_ntpath.py From ironpython2 with Apache License 2.0 | 6 votes |
def test_splitunc(self): tester('ntpath.splitunc("c:\\foo\\bar")', ('', 'c:\\foo\\bar')) tester('ntpath.splitunc("c:/foo/bar")', ('', 'c:/foo/bar')) tester('ntpath.splitunc("\\\\conky\\mountpoint\\foo\\bar")', ('\\\\conky\\mountpoint', '\\foo\\bar')) tester('ntpath.splitunc("//conky/mountpoint/foo/bar")', ('//conky/mountpoint', '/foo/bar')) tester('ntpath.splitunc("\\\\\\conky\\mountpoint\\foo\\bar")', ('', '\\\\\\conky\\mountpoint\\foo\\bar')) tester('ntpath.splitunc("///conky/mountpoint/foo/bar")', ('', '///conky/mountpoint/foo/bar')) tester('ntpath.splitunc("\\\\conky\\\\mountpoint\\foo\\bar")', ('', '\\\\conky\\\\mountpoint\\foo\\bar')) tester('ntpath.splitunc("//conky//mountpoint/foo/bar")', ('', '//conky//mountpoint/foo/bar')) if test_support.have_unicode: self.assertEqual(ntpath.splitunc(u'//conky/MOUNTPO%cNT/foo/bar' % 0x0130), (u'//conky/MOUNTPO%cNT' % 0x0130, u'/foo/bar'))
Example #6
Source File: test_StringIO.py From ironpython2 with Apache License 2.0 | 6 votes |
def test_unicode(self): if not test_support.have_unicode: return # The StringIO module also supports concatenating Unicode # snippets to larger Unicode strings. This is tested by this # method. Note that cStringIO does not support this extension. f = self.MODULE.StringIO() f.write(self._line[:6]) f.seek(3) f.write(unicode(self._line[20:26])) f.write(unicode(self._line[52])) s = f.getvalue() self.assertEqual(s, unicode('abcuvwxyz!')) self.assertEqual(type(s), types.UnicodeType)
Example #7
Source File: test_StringIO.py From ironpython2 with Apache License 2.0 | 6 votes |
def test_unicode(self): if not test_support.have_unicode: return # The cStringIO module converts Unicode strings to character # strings when writing them to cStringIO objects. # Check that this works. f = self.MODULE.StringIO() f.write(u'abcde') s = f.getvalue() self.assertEqual(s, 'abcde') self.assertEqual(type(s), str) f = self.MODULE.StringIO(u'abcde') s = f.getvalue() self.assertEqual(s, 'abcde') self.assertEqual(type(s), str) self.assertRaises(UnicodeEncodeError, self.MODULE.StringIO, u'\xf4')
Example #8
Source File: test_tcl.py From ironpython2 with Apache License 2.0 | 6 votes |
def test_getboolean(self): tcl = self.interp.tk self.assertIs(tcl.getboolean('on'), True) self.assertIs(tcl.getboolean('1'), True) self.assertIs(tcl.getboolean(u'on'), True) self.assertIs(tcl.getboolean(u'1'), True) self.assertIs(tcl.getboolean(42), True) self.assertIs(tcl.getboolean(0), False) self.assertIs(tcl.getboolean(42L), True) self.assertIs(tcl.getboolean(0L), False) self.assertRaises(TypeError, tcl.getboolean) self.assertRaises(TypeError, tcl.getboolean, 'on', '1') self.assertRaises(TypeError, tcl.getboolean, 1.0) self.assertRaises(TclError, tcl.getboolean, 'a') self.assertRaises((TypeError, ValueError, TclError), tcl.getboolean, 'on\0') if test_support.have_unicode: self.assertIs(tcl.getboolean(unicode('on')), True) self.assertRaises((UnicodeEncodeError, ValueError, TclError), tcl.getboolean, 'on' + unichr(0xd800))
Example #9
Source File: test_StringIO.py From BinderFilter with MIT License | 6 votes |
def test_unicode(self): if not test_support.have_unicode: return # The StringIO module also supports concatenating Unicode # snippets to larger Unicode strings. This is tested by this # method. Note that cStringIO does not support this extension. f = self.MODULE.StringIO() f.write(self._line[:6]) f.seek(3) f.write(unicode(self._line[20:26])) f.write(unicode(self._line[52])) s = f.getvalue() self.assertEqual(s, unicode('abcuvwxyz!')) self.assertEqual(type(s), types.UnicodeType)
Example #10
Source File: test_StringIO.py From BinderFilter with MIT License | 6 votes |
def test_unicode(self): if not test_support.have_unicode: return # The cStringIO module converts Unicode strings to character # strings when writing them to cStringIO objects. # Check that this works. f = self.MODULE.StringIO() f.write(u'abcde') s = f.getvalue() self.assertEqual(s, 'abcde') self.assertEqual(type(s), str) f = self.MODULE.StringIO(u'abcde') s = f.getvalue() self.assertEqual(s, 'abcde') self.assertEqual(type(s), str) self.assertRaises(UnicodeEncodeError, self.MODULE.StringIO, u'\xf4')
Example #11
Source File: test_isinstance.py From BinderFilter with MIT License | 6 votes |
def test_subclass_tuple(self): # test with a tuple as the second argument classes self.assertEqual(True, issubclass(Child, (Child,))) self.assertEqual(True, issubclass(Child, (Super,))) self.assertEqual(False, issubclass(Super, (Child,))) self.assertEqual(True, issubclass(Super, (Child, Super))) self.assertEqual(False, issubclass(Child, ())) self.assertEqual(True, issubclass(Super, (Child, (Super,)))) self.assertEqual(True, issubclass(NewChild, (NewChild,))) self.assertEqual(True, issubclass(NewChild, (NewSuper,))) self.assertEqual(False, issubclass(NewSuper, (NewChild,))) self.assertEqual(True, issubclass(NewSuper, (NewChild, NewSuper))) self.assertEqual(False, issubclass(NewChild, ())) self.assertEqual(True, issubclass(NewSuper, (NewChild, (NewSuper,)))) self.assertEqual(True, issubclass(int, (long, (float, int)))) if test_support.have_unicode: self.assertEqual(True, issubclass(str, (unicode, (Child, NewChild, basestring))))
Example #12
Source File: test_int.py From BinderFilter with MIT License | 6 votes |
def test_valid_non_numeric_input_types_for_x(self): # Test possible valid non-numeric types for x, including subclasses # of the allowed built-in types. class CustomStr(str): pass values = ['100', CustomStr('100')] if have_unicode: class CustomUnicode(unicode): pass values += [unicode('100'), CustomUnicode(unicode('100'))] for x in values: msg = 'x has value %s and type %s' % (x, type(x).__name__) try: self.assertEqual(int(x), 100, msg=msg) self.assertEqual(int(x, 2), 4, msg=msg) except TypeError, err: raise AssertionError('For %s got TypeError: %s' % (type(x).__name__, err))
Example #13
Source File: test_float.py From oss-ftp with MIT License | 6 votes |
def test_float(self): self.assertEqual(float(3.14), 3.14) self.assertEqual(float(314), 314.0) self.assertEqual(float(314L), 314.0) self.assertEqual(float(" 3.14 "), 3.14) self.assertRaises(ValueError, float, " 0x3.1 ") self.assertRaises(ValueError, float, " -0x3.p-1 ") self.assertRaises(ValueError, float, " +0x3.p-1 ") self.assertRaises(ValueError, float, "++3.14") self.assertRaises(ValueError, float, "+-3.14") self.assertRaises(ValueError, float, "-+3.14") self.assertRaises(ValueError, float, "--3.14") # check that we don't accept alternate exponent markers self.assertRaises(ValueError, float, "-1.7d29") self.assertRaises(ValueError, float, "3D-14") if test_support.have_unicode: self.assertEqual(float(unicode(" 3.14 ")), 3.14) self.assertEqual(float(unicode(" \u0663.\u0661\u0664 ",'raw-unicode-escape')), 3.14) # extra long strings should no longer be a problem # (in 2.6, long unicode inputs to float raised ValueError) float('.' + '1'*1000) float(unicode('.' + '1'*1000))
Example #14
Source File: test_StringIO.py From oss-ftp with MIT License | 6 votes |
def test_unicode(self): if not test_support.have_unicode: return # The StringIO module also supports concatenating Unicode # snippets to larger Unicode strings. This is tested by this # method. Note that cStringIO does not support this extension. f = self.MODULE.StringIO() f.write(self._line[:6]) f.seek(3) f.write(unicode(self._line[20:26])) f.write(unicode(self._line[52])) s = f.getvalue() self.assertEqual(s, unicode('abcuvwxyz!')) self.assertEqual(type(s), types.UnicodeType)
Example #15
Source File: test_StringIO.py From oss-ftp with MIT License | 6 votes |
def test_unicode(self): if not test_support.have_unicode: return # The cStringIO module converts Unicode strings to character # strings when writing them to cStringIO objects. # Check that this works. f = self.MODULE.StringIO() f.write(u'abcde') s = f.getvalue() self.assertEqual(s, 'abcde') self.assertEqual(type(s), str) f = self.MODULE.StringIO(u'abcde') s = f.getvalue() self.assertEqual(s, 'abcde') self.assertEqual(type(s), str) self.assertRaises(UnicodeEncodeError, self.MODULE.StringIO, u'\xf4')
Example #16
Source File: test_float.py From ironpython2 with Apache License 2.0 | 6 votes |
def test_non_numeric_input_types(self): # Test possible non-numeric types for the argument x, including # subclasses of the explicitly documented accepted types. class CustomStr(str): pass class CustomByteArray(bytearray): pass factories = [str, bytearray, CustomStr, CustomByteArray, buffer] if test_support.have_unicode: class CustomUnicode(unicode): pass factories += [unicode, CustomUnicode] for f in factories: with test_support.check_py3k_warnings(quiet=True): x = f(" 3.14 ") msg = 'x has value %s and type %s' % (x, type(x).__name__) try: self.assertEqual(float(x), 3.14, msg=msg) except TypeError, err: raise AssertionError('For %s got TypeError: %s' % (type(x).__name__, err)) errmsg = "could not convert" with self.assertRaisesRegexp(ValueError, errmsg, msg=msg), \ test_support.check_py3k_warnings(quiet=True): float(f('A' * 0x10))
Example #17
Source File: test_re.py From oss-ftp with MIT License | 6 votes |
def test_ignore_case(self): self.assertEqual(re.match("abc", "ABC", re.I).group(0), "ABC") self.assertEqual(re.match("abc", u"ABC", re.I).group(0), "ABC") self.assertEqual(re.match(r"(a\s[^a])", "a b", re.I).group(1), "a b") self.assertEqual(re.match(r"(a\s[^a]*)", "a bb", re.I).group(1), "a bb") self.assertEqual(re.match(r"(a\s[abc])", "a b", re.I).group(1), "a b") self.assertEqual(re.match(r"(a\s[abc]*)", "a bb", re.I).group(1), "a bb") self.assertEqual(re.match(r"((a)\s\2)", "a a", re.I).group(1), "a a") self.assertEqual(re.match(r"((a)\s\2*)", "a aa", re.I).group(1), "a aa") self.assertEqual(re.match(r"((a)\s(abc|a))", "a a", re.I).group(1), "a a") self.assertEqual(re.match(r"((a)\s(abc|a)*)", "a aa", re.I).group(1), "a aa") if have_unicode: assert u(r'\u212a').lower() == u'k' # 'K' self.assertTrue(re.match(ur'K', u(r'\u212a'), re.U | re.I)) self.assertTrue(re.match(ur'k', u(r'\u212a'), re.U | re.I)) self.assertTrue(re.match(u(r'\u212a'), u'K', re.U | re.I)) self.assertTrue(re.match(u(r'\u212a'), u'k', re.U | re.I)) assert u(r'\u017f').upper() == u'S' # 'ſ' self.assertTrue(re.match(ur'S', u(r'\u017f'), re.U | re.I)) self.assertTrue(re.match(ur's', u(r'\u017f'), re.U | re.I)) self.assertTrue(re.match(u(r'\u017f'), u'S', re.U | re.I)) self.assertTrue(re.match(u(r'\u017f'), u's', re.U | re.I))
Example #18
Source File: test_re.py From oss-ftp with MIT License | 6 votes |
def test_ignore_case_set(self): self.assertTrue(re.match(r'[19A]', 'A', re.I)) self.assertTrue(re.match(r'[19a]', 'a', re.I)) self.assertTrue(re.match(r'[19a]', 'A', re.I)) self.assertTrue(re.match(r'[19A]', 'a', re.I)) if have_unicode: self.assertTrue(re.match(ur'[19A]', u'A', re.U | re.I)) self.assertTrue(re.match(ur'[19a]', u'a', re.U | re.I)) self.assertTrue(re.match(ur'[19a]', u'A', re.U | re.I)) self.assertTrue(re.match(ur'[19A]', u'a', re.U | re.I)) assert u(r'\u212a').lower() == u'k' # 'K' self.assertTrue(re.match(u(r'[19K]'), u(r'\u212a'), re.U | re.I)) self.assertTrue(re.match(u(r'[19k]'), u(r'\u212a'), re.U | re.I)) self.assertTrue(re.match(u(r'[19\u212a]'), u'K', re.U | re.I)) self.assertTrue(re.match(u(r'[19\u212a]'), u'k', re.U | re.I)) assert u(r'\u017f').upper() == u'S' # 'ſ' self.assertTrue(re.match(ur'[19S]', u(r'\u017f'), re.U | re.I)) self.assertTrue(re.match(ur'[19s]', u(r'\u017f'), re.U | re.I)) self.assertTrue(re.match(u(r'[19\u017f]'), u'S', re.U | re.I)) self.assertTrue(re.match(u(r'[19\u017f]'), u's', re.U | re.I))
Example #19
Source File: test_int.py From oss-ftp with MIT License | 6 votes |
def test_valid_non_numeric_input_types_for_x(self): # Test possible valid non-numeric types for x, including subclasses # of the allowed built-in types. class CustomStr(str): pass values = ['100', CustomStr('100')] if have_unicode: class CustomUnicode(unicode): pass values += [unicode('100'), CustomUnicode(unicode('100'))] for x in values: msg = 'x has value %s and type %s' % (x, type(x).__name__) try: self.assertEqual(int(x), 100, msg=msg) self.assertEqual(int(x, 2), 4, msg=msg) except TypeError, err: raise AssertionError('For %s got TypeError: %s' % (type(x).__name__, err))
Example #20
Source File: test_float.py From gcblue with BSD 3-Clause "New" or "Revised" License | 6 votes |
def test_float(self): self.assertEqual(float(3.14), 3.14) self.assertEqual(float(314), 314.0) self.assertEqual(float(314L), 314.0) self.assertEqual(float(" 3.14 "), 3.14) self.assertRaises(ValueError, float, " 0x3.1 ") self.assertRaises(ValueError, float, " -0x3.p-1 ") self.assertRaises(ValueError, float, " +0x3.p-1 ") self.assertRaises(ValueError, float, "++3.14") self.assertRaises(ValueError, float, "+-3.14") self.assertRaises(ValueError, float, "-+3.14") self.assertRaises(ValueError, float, "--3.14") # check that we don't accept alternate exponent markers self.assertRaises(ValueError, float, "-1.7d29") self.assertRaises(ValueError, float, "3D-14") if test_support.have_unicode: self.assertEqual(float(unicode(" 3.14 ")), 3.14) self.assertEqual(float(unicode(" \u0663.\u0661\u0664 ",'raw-unicode-escape')), 3.14) # extra long strings should no longer be a problem # (in 2.6, long unicode inputs to float raised ValueError) float('.' + '1'*1000) float(unicode('.' + '1'*1000))
Example #21
Source File: test_StringIO.py From gcblue with BSD 3-Clause "New" or "Revised" License | 6 votes |
def test_unicode(self): if not test_support.have_unicode: return # The StringIO module also supports concatenating Unicode # snippets to larger Unicode strings. This is tested by this # method. Note that cStringIO does not support this extension. f = self.MODULE.StringIO() f.write(self._line[:6]) f.seek(3) f.write(unicode(self._line[20:26])) f.write(unicode(self._line[52])) s = f.getvalue() self.assertEqual(s, unicode('abcuvwxyz!')) self.assertEqual(type(s), types.UnicodeType)
Example #22
Source File: test_StringIO.py From gcblue with BSD 3-Clause "New" or "Revised" License | 6 votes |
def test_unicode(self): if not test_support.have_unicode: return # The cStringIO module converts Unicode strings to character # strings when writing them to cStringIO objects. # Check that this works. f = self.MODULE.StringIO() f.write(u'abcde') s = f.getvalue() self.assertEqual(s, 'abcde') self.assertEqual(type(s), str) f = self.MODULE.StringIO(u'abcde') s = f.getvalue() self.assertEqual(s, 'abcde') self.assertEqual(type(s), str) self.assertRaises(UnicodeEncodeError, self.MODULE.StringIO, u'\xf4')
Example #23
Source File: test_isinstance.py From gcblue with BSD 3-Clause "New" or "Revised" License | 6 votes |
def test_subclass_tuple(self): # test with a tuple as the second argument classes self.assertEqual(True, issubclass(Child, (Child,))) self.assertEqual(True, issubclass(Child, (Super,))) self.assertEqual(False, issubclass(Super, (Child,))) self.assertEqual(True, issubclass(Super, (Child, Super))) self.assertEqual(False, issubclass(Child, ())) self.assertEqual(True, issubclass(Super, (Child, (Super,)))) self.assertEqual(True, issubclass(NewChild, (NewChild,))) self.assertEqual(True, issubclass(NewChild, (NewSuper,))) self.assertEqual(False, issubclass(NewSuper, (NewChild,))) self.assertEqual(True, issubclass(NewSuper, (NewChild, NewSuper))) self.assertEqual(False, issubclass(NewChild, ())) self.assertEqual(True, issubclass(NewSuper, (NewChild, (NewSuper,)))) self.assertEqual(True, issubclass(int, (long, (float, int)))) if test_support.have_unicode: self.assertEqual(True, issubclass(str, (unicode, (Child, NewChild, basestring))))
Example #24
Source File: test_int.py From gcblue with BSD 3-Clause "New" or "Revised" License | 6 votes |
def test_valid_non_numeric_input_types_for_x(self): # Test possible valid non-numeric types for x, including subclasses # of the allowed built-in types. class CustomStr(str): pass values = ['100', CustomStr('100')] if have_unicode: class CustomUnicode(unicode): pass values += [unicode('100'), CustomUnicode(unicode('100'))] for x in values: msg = 'x has value %s and type %s' % (x, type(x).__name__) try: self.assertEqual(int(x), 100, msg=msg) self.assertEqual(int(x, 2), 4, msg=msg) except TypeError, err: raise AssertionError('For %s got TypeError: %s' % (type(x).__name__, err))
Example #25
Source File: test_StringIO.py From medicare-demo with Apache License 2.0 | 6 votes |
def test_unicode(self): if not test_support.have_unicode: return # The StringIO module also supports concatenating Unicode # snippets to larger Unicode strings. This is tested by this # method. Note that cStringIO does not support this extension. f = self.MODULE.StringIO() f.write(self._line[:6]) f.seek(3) f.write(unicode(self._line[20:26])) f.write(unicode(self._line[52])) s = f.getvalue() self.assertEqual(s, unicode('abcuvwxyz!')) self.assertEqual(type(s), types.UnicodeType)
Example #26
Source File: test_isinstance.py From medicare-demo with Apache License 2.0 | 6 votes |
def test_subclass_tuple(self): # test with a tuple as the second argument classes self.assertEqual(True, issubclass(Child, (Child,))) self.assertEqual(True, issubclass(Child, (Super,))) self.assertEqual(False, issubclass(Super, (Child,))) self.assertEqual(True, issubclass(Super, (Child, Super))) self.assertEqual(False, issubclass(Child, ())) self.assertEqual(True, issubclass(Super, (Child, (Super,)))) self.assertEqual(True, issubclass(NewChild, (NewChild,))) self.assertEqual(True, issubclass(NewChild, (NewSuper,))) self.assertEqual(False, issubclass(NewSuper, (NewChild,))) self.assertEqual(True, issubclass(NewSuper, (NewChild, NewSuper))) self.assertEqual(False, issubclass(NewChild, ())) self.assertEqual(True, issubclass(NewSuper, (NewChild, (NewSuper,)))) self.assertEqual(True, issubclass(int, (long, (float, int)))) if test_support.have_unicode: self.assertEqual(True, issubclass(str, (unicode, (Child, NewChild, basestring))))
Example #27
Source File: test_float.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 6 votes |
def test_float(self): self.assertEqual(float(3.14), 3.14) self.assertEqual(float(314), 314.0) self.assertEqual(float(314L), 314.0) self.assertEqual(float(" 3.14 "), 3.14) self.assertRaises(ValueError, float, " 0x3.1 ") self.assertRaises(ValueError, float, " -0x3.p-1 ") self.assertRaises(ValueError, float, " +0x3.p-1 ") self.assertRaises(ValueError, float, "++3.14") self.assertRaises(ValueError, float, "+-3.14") self.assertRaises(ValueError, float, "-+3.14") self.assertRaises(ValueError, float, "--3.14") # check that we don't accept alternate exponent markers self.assertRaises(ValueError, float, "-1.7d29") self.assertRaises(ValueError, float, "3D-14") if test_support.have_unicode: self.assertEqual(float(unicode(" 3.14 ")), 3.14) self.assertEqual(float(unicode(" \u0663.\u0661\u0664 ",'raw-unicode-escape')), 3.14) # extra long strings should no longer be a problem # (in 2.6, long unicode inputs to float raised ValueError) float('.' + '1'*1000) float(unicode('.' + '1'*1000))
Example #28
Source File: test_StringIO.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 6 votes |
def test_unicode(self): if not test_support.have_unicode: return # The StringIO module also supports concatenating Unicode # snippets to larger Unicode strings. This is tested by this # method. Note that cStringIO does not support this extension. f = self.MODULE.StringIO() f.write(self._line[:6]) f.seek(3) f.write(unicode(self._line[20:26])) f.write(unicode(self._line[52])) s = f.getvalue() self.assertEqual(s, unicode('abcuvwxyz!')) self.assertEqual(type(s), types.UnicodeType)
Example #29
Source File: test_StringIO.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 6 votes |
def test_unicode(self): if not test_support.have_unicode: return # The cStringIO module converts Unicode strings to character # strings when writing them to cStringIO objects. # Check that this works. f = self.MODULE.StringIO() f.write(u'abcde') s = f.getvalue() self.assertEqual(s, 'abcde') self.assertEqual(type(s), str) f = self.MODULE.StringIO(u'abcde') s = f.getvalue() self.assertEqual(s, 'abcde') self.assertEqual(type(s), str) if not test_support.is_jython: # FIXME re-enable in a future release # On Jython, this should raise UnicodeEncodeError, however, we # have to do more work on preventing inadvertent mixing of Unicode # into String-supporting objects like StringBuilder self.assertRaises(UnicodeEncodeError, self.MODULE.StringIO, u'\xf4')
Example #30
Source File: test_isinstance.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 6 votes |
def test_subclass_tuple(self): # test with a tuple as the second argument classes self.assertEqual(True, issubclass(Child, (Child,))) self.assertEqual(True, issubclass(Child, (Super,))) self.assertEqual(False, issubclass(Super, (Child,))) self.assertEqual(True, issubclass(Super, (Child, Super))) self.assertEqual(False, issubclass(Child, ())) self.assertEqual(True, issubclass(Super, (Child, (Super,)))) self.assertEqual(True, issubclass(NewChild, (NewChild,))) self.assertEqual(True, issubclass(NewChild, (NewSuper,))) self.assertEqual(False, issubclass(NewSuper, (NewChild,))) self.assertEqual(True, issubclass(NewSuper, (NewChild, NewSuper))) self.assertEqual(False, issubclass(NewChild, ())) self.assertEqual(True, issubclass(NewSuper, (NewChild, (NewSuper,)))) self.assertEqual(True, issubclass(int, (long, (float, int)))) if test_support.have_unicode: self.assertEqual(True, issubclass(str, (unicode, (Child, NewChild, basestring))))