MCPcopy Index your code
hub / github.com/python/cpython / test_quoting

Method test_quoting

Lib/test/test_urllib.py:1415–1440  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1413 (result, expected_path))
1414
1415 def test_quoting(self):
1416 # Test automatic quoting and unquoting works for pathnam2url() and
1417 # url2pathname() respectively
1418 given = os.path.join("needs", "quot=ing", "here")
1419 expect = "needs/%s/here" % urllib.parse.quote("quot=ing")
1420 result = urllib.request.pathname2url(given)
1421 self.assertEqual(expect, result,
1422 "pathname2url() failed; %s != %s" %
1423 (expect, result))
1424 expect = given
1425 result = urllib.request.url2pathname(result)
1426 self.assertEqual(expect, result,
1427 "url2pathname() failed; %s != %s" %
1428 (expect, result))
1429 given = os.path.join("make sure", "using_quote")
1430 expect = "%s/using_quote" % urllib.parse.quote("make sure")
1431 result = urllib.request.pathname2url(given)
1432 self.assertEqual(expect, result,
1433 "pathname2url() failed; %s != %s" %
1434 (expect, result))
1435 given = "make+sure/using_unquote"
1436 expect = os.path.join("make+sure", "using_unquote")
1437 result = urllib.request.url2pathname(given)
1438 self.assertEqual(expect, result,
1439 "url2pathname() failed; %s != %s" %
1440 (expect, result))
1441
1442 def test_pathname2url(self):
1443 # Test cases common to Windows and POSIX.

Callers

nothing calls this directly

Calls 3

quoteMethod · 0.80
joinMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected