Beispiel #1
0
def test_getupper_getlower_unicode_ascii_shortcut():
    from rpython.rlib.unicodedata import unicodedb
    try:
        rsre_char.set_unicode_db(None)
        for i in range(128):
            # works despite not having a unicode db
            rsre_char.getlower(i, SRE_FLAG_UNICODE)
            rsre_char.getupper(i, SRE_FLAG_UNICODE)
    finally:
        rsre_char.set_unicode_db(unicodedb)
Beispiel #2
0
def test_getlower():
    assert rsre_char.getlower(ord('A'), 0) == ord('a')
    assert rsre_char.getlower(ord('2'), 0) == ord('2')
    assert rsre_char.getlower(10, 0) == 10
    assert rsre_char.getlower(UPPER_PI, 0) == UPPER_PI
    #
    assert rsre_char.getlower(ord('A'), SRE_FLAG_UNICODE) == ord('a')
    assert rsre_char.getlower(ord('2'), SRE_FLAG_UNICODE) == ord('2')
    assert rsre_char.getlower(10, SRE_FLAG_UNICODE) == 10
    assert rsre_char.getlower(UPPER_PI, SRE_FLAG_UNICODE) == LOWER_PI
    #
    # xxx the following cases are like CPython's.  They are obscure.
    # (iko) that's a nice way to say "broken"
    assert rsre_char.getlower(UPPER_PI, SRE_FLAG_LOCALE) == UPPER_PI
    assert rsre_char.getlower(UPPER_PI, SRE_FLAG_LOCALE | SRE_FLAG_UNICODE) \
                                                         == UPPER_PI
Beispiel #3
0
def test_getlower():
    assert rsre_char.getlower(ord('A'), 0) == ord('a')
    assert rsre_char.getlower(ord('2'), 0) == ord('2')
    assert rsre_char.getlower(10, 0) == 10
    assert rsre_char.getlower(UPPER_PI, 0) == UPPER_PI
    #
    assert rsre_char.getlower(ord('A'), SRE_FLAG_UNICODE) == ord('a')
    assert rsre_char.getlower(ord('2'), SRE_FLAG_UNICODE) == ord('2')
    assert rsre_char.getlower(10, SRE_FLAG_UNICODE) == 10
    assert rsre_char.getlower(UPPER_PI, SRE_FLAG_UNICODE) == LOWER_PI
    #
    # xxx the following cases are like CPython's.  They are obscure.
    # (iko) that's a nice way to say "broken"
    assert rsre_char.getlower(UPPER_PI, SRE_FLAG_LOCALE) == UPPER_PI
    assert rsre_char.getlower(UPPER_PI, SRE_FLAG_LOCALE | SRE_FLAG_UNICODE) \
                                                         == UPPER_PI
Beispiel #4
0
 def lowstr(self, index):
     c = self.str(index)
     return rsre_char.getlower(c, self.flags)
Beispiel #5
0
def w_getlower(space, char_ord, flags):
    return space.newint(getlower(char_ord, flags))
Beispiel #6
0
 def lowstr(self, index):
     c = self.str(index)
     return rsre_char.getlower(c, self.flags)
Beispiel #7
0
def w_getlower(space, char_ord, flags):
    return space.wrap(getlower(char_ord, flags))
Beispiel #8
0
def w_getlower(space, char_ord, flags):
    return space.wrap(getlower(char_ord, flags))