Funktionierender Prototyp des Serious Games zur Vermittlung von Wissen zu Software-Engineering-Arbeitsmodellen.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

test_parse.py 1.1KB

12345678910111213141516171819202122232425262728293031323334353637
  1. # -*- coding: utf-8 -*-
  2. from __future__ import unicode_literals
  3. from .common import HyperlinkTestCase
  4. from hyperlink import parse, EncodedURL, DecodedURL
  5. BASIC_URL = "http://example.com/#"
  6. TOTAL_URL = (
  7. "https://%75%73%65%72:%00%00%00%00@xn--bcher-kva.ch:8080"
  8. "/a/nice%20nice/./path/?zot=23%25&zut#frég"
  9. )
  10. UNDECODABLE_FRAG_URL = TOTAL_URL + "%C3"
  11. # the %C3 above percent-decodes to an unpaired \xc3 byte which makes this
  12. # invalid utf8
  13. class TestURL(HyperlinkTestCase):
  14. def test_parse(self):
  15. # type: () -> None
  16. purl = parse(TOTAL_URL)
  17. assert isinstance(purl, DecodedURL)
  18. assert purl.user == "user"
  19. assert purl.get("zot") == ["23%"]
  20. assert purl.fragment == "frég"
  21. purl2 = parse(TOTAL_URL, decoded=False)
  22. assert isinstance(purl2, EncodedURL)
  23. assert purl2.get("zot") == ["23%25"]
  24. with self.assertRaises(UnicodeDecodeError):
  25. purl3 = parse(UNDECODABLE_FRAG_URL)
  26. purl3 = parse(UNDECODABLE_FRAG_URL, lazy=True)
  27. with self.assertRaises(UnicodeDecodeError):
  28. purl3.fragment