def test_normalize_encode_can_take_unicode_with_non_ascii_with_slash(self): uncd = u'núcleo/núcleo' normal = normalize(type=uncd, namespace=uncd, name=uncd, version=uncd, qualifiers='a=' + uncd, subpath=uncd, encode=True) expected = ('n%c3%bacleo/n%c3%bacleo', 'n%C3%BAcleo/n%C3%BAcleo', 'n%C3%BAcleo/n%C3%BAcleo', 'n%C3%BAcleo/n%C3%BAcleo', 'a=n%C3%BAcleo/n%C3%BAcleo', 'n%C3%BAcleo/n%C3%BAcleo') assert expected == normal
def test_normalize_encode_always_reencodes(self): uncd = u'n%c3%bacleo/n%c3%bacleo' normal = normalize(type=uncd, namespace=uncd, name=uncd, version=uncd, qualifiers='a=' + uncd, subpath=uncd, encode=True) expected = (u'n%25c3%25bacleo/n%25c3%25bacleo', u'n%25c3%25bacleo/n%25c3%25bacleo', u'n%25c3%25bacleo/n%25c3%25bacleo', u'n%25c3%25bacleo/n%25c3%25bacleo', u'a=n%25c3%25bacleo/n%25c3%25bacleo', u'n%25c3%25bacleo/n%25c3%25bacleo') assert expected == normal
def test_normalize_decode_can_take_unicode_with_non_ascii_with_slash(self): uncd = u'núcleo/núcleo' normal = normalize(type=uncd, namespace=uncd, name=uncd, version=uncd, qualifiers='a=' + uncd, subpath=uncd, encode=False) expected = ( 'núcleo/núcleo', 'núcleo/núcleo', 'núcleo/núcleo', 'núcleo/núcleo', { 'a': 'núcleo/núcleo' }, 'núcleo/núcleo', ) assert expected == normal