MCPcopy
hub / github.com/django/django / test_iri_to_uri

Method test_iri_to_uri

tests/utils_tests/test_encoding.py:155–175  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

153 self.assertEqual(filepath_to_uri(Path("upload\\test.png")), "upload/test.png")
154
155 def test_iri_to_uri(self):
156 cases = [
157 # Valid UTF-8 sequences are encoded.
158 ("red%09rosé#red", "red%09ros%C3%A9#red"),
159 ("/blog/for/Jürgen Münster/", "/blog/for/J%C3%BCrgen%20M%C3%BCnster/"),
160 (
161 "locations/%s" % quote_plus("Paris & Orléans"),
162 "locations/Paris+%26+Orl%C3%A9ans",
163 ),
164 # Reserved chars remain unescaped.
165 ("%&", "%&"),
166 ("red&♥ros%#red", "red&%E2%99%A5ros%#red"),
167 (gettext_lazy("red&♥ros%#red"), "red&%E2%99%A5ros%#red"),
168 ]
169
170 for iri, uri in cases:
171 with self.subTest(iri):
172 self.assertEqual(iri_to_uri(iri), uri)
173
174 # Test idempotency.
175 self.assertEqual(iri_to_uri(iri_to_uri(iri)), uri)
176
177 def test_uri_to_iri(self):
178 cases = [

Callers

nothing calls this directly

Calls 1

iri_to_uriFunction · 0.90

Tested by

no test coverage detected