Back to index

python3.2  3.2.2
Public Member Functions
test.test_urllib.Pathname_Tests Class Reference

List of all members.

Public Member Functions

def test_basic
def test_quoting
def test_ntpath

Detailed Description

Test pathname2url() and url2pathname()

Definition at line 985 of file test_urllib.py.


Member Function Documentation

Definition at line 988 of file test_urllib.py.

00988 
00989     def test_basic(self):
00990         # Make sure simple tests pass
00991         expected_path = os.path.join("parts", "of", "a", "path")
00992         expected_url = "parts/of/a/path"
00993         result = urllib.request.pathname2url(expected_path)
00994         self.assertEqual(expected_url, result,
00995                          "pathname2url() failed; %s != %s" %
00996                          (result, expected_url))
00997         result = urllib.request.url2pathname(expected_url)
00998         self.assertEqual(expected_path, result,
00999                          "url2pathame() failed; %s != %s" %
01000                          (result, expected_path))

Here is the call graph for this function:

Definition at line 1030 of file test_urllib.py.

01030 
01031     def test_ntpath(self):
01032         given = ('/C:/', '///C:/', '/C|//')
01033         expect = 'C:\\'
01034         for url in given:
01035             result = urllib.request.url2pathname(url)
01036             self.assertEqual(expect, result,
01037                              'urllib.request..url2pathname() failed; %s != %s' %
01038                              (expect, result))
01039         given = '///C|/path'
01040         expect = 'C:\\path'
01041         result = urllib.request.url2pathname(given)
01042         self.assertEqual(expect, result,
01043                          'urllib.request.url2pathname() failed; %s != %s' %
01044                          (expect, result))

Here is the call graph for this function:

Definition at line 1001 of file test_urllib.py.

01001 
01002     def test_quoting(self):
01003         # Test automatic quoting and unquoting works for pathnam2url() and
01004         # url2pathname() respectively
01005         given = os.path.join("needs", "quot=ing", "here")
01006         expect = "needs/%s/here" % urllib.parse.quote("quot=ing")
01007         result = urllib.request.pathname2url(given)
01008         self.assertEqual(expect, result,
01009                          "pathname2url() failed; %s != %s" %
01010                          (expect, result))
01011         expect = given
01012         result = urllib.request.url2pathname(result)
01013         self.assertEqual(expect, result,
01014                          "url2pathname() failed; %s != %s" %
01015                          (expect, result))
01016         given = os.path.join("make sure", "using_quote")
01017         expect = "%s/using_quote" % urllib.parse.quote("make sure")
01018         result = urllib.request.pathname2url(given)
01019         self.assertEqual(expect, result,
01020                          "pathname2url() failed; %s != %s" %
01021                          (expect, result))
01022         given = "make+sure/using_unquote"
01023         expect = os.path.join("make+sure", "using_unquote")
01024         result = urllib.request.url2pathname(given)
01025         self.assertEqual(expect, result,
01026                          "url2pathname() failed; %s != %s" %
01027                          (expect, result))

Here is the call graph for this function:


The documentation for this class was generated from the following file: