本文整理汇总了Python中test.test_urllib2.sanepathname2url函数的典型用法代码示例。如果您正苦于以下问题:Python sanepathname2url函数的具体用法?Python sanepathname2url怎么用?Python sanepathname2url使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sanepathname2url函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_file
def test_file(self):
TESTFN = test_support.TESTFN
f = open(TESTFN, 'w')
try:
f.write('hi there\n')
f.close()
urls = [
'file:'+sanepathname2url(os.path.abspath(TESTFN)),
('file:///nonsensename/etc/passwd', None, urllib2.URLError),
]
self._test_urls(urls, self._extra_handlers(), retry=True)
finally:
os.remove(TESTFN)
示例2: test_file
def test_file(self):
TESTFN = support.TESTFN
f = open(TESTFN, "w")
try:
f.write("hi there\n")
f.close()
urls = [
"file:" + sanepathname2url(os.path.abspath(TESTFN)),
("file:///nonsensename/etc/passwd", None, urllib.error.URLError),
]
self._test_urls(urls, self._extra_handlers(), retry=True)
finally:
os.remove(TESTFN)
示例3: test_file
def test_file(self):
TESTFN = test_support.TESTFN
f = open(TESTFN, "w")
try:
f.write("hi there\n")
f.close()
urls = [
"file:" + sanepathname2url(os.path.abspath(TESTFN)),
("file:///nonsensename/etc/passwd", None, urllib2.URLError),
]
self._test_urls(urls, self._extra_handlers(), retry=True)
finally:
os.remove(TESTFN)
self.assertRaises(ValueError, urllib2.urlopen, "./relative_path/to/file")
示例4: test_file
def test_file(self):
TESTFN = support.TESTFN
f = open(TESTFN, 'w')
try:
f.write('hi there\n')
f.close()
urls = [
'file:'+sanepathname2url(os.path.abspath(TESTFN)),
('file:///nonsensename/etc/passwd', None, urllib.error.URLError),
]
self._test_urls(urls, self._extra_handlers(), retry=True)
finally:
os.remove(TESTFN)
self.assertRaises(ValueError, urllib.request.urlopen, './relative_path/to/file')
示例5: test_file
def test_file(self):
TESTFN = test_support.TESTFN
f = open(TESTFN, 'w')
try:
f.write('hi there\n')
f.close()
urls = [
'file:'+sanepathname2url(os.path.abspath(TESTFN)),
# XXX bug, should raise URLError
#('file://nonsensename/etc/passwd', None, urllib2.URLError)
('file://nonsensename/etc/passwd', None, (EnvironmentError, socket.error))
]
self._test_urls(urls, self._extra_handlers())
finally:
os.remove(TESTFN)