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

Method test_file

Lib/test/test_urllib2net.py:187–202  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

185 self._test_urls([url], cache_handlers, retry=False)
186
187 def test_file(self):
188 TESTFN = os_helper.TESTFN
189 f = open(TESTFN, 'w')
190 try:
191 f.write('hi there\n')
192 f.close()
193 urls = [
194 urllib.request.pathname2url(os.path.abspath(TESTFN), add_scheme=True),
195 ('file:///nonsensename/etc/passwd', None,
196 urllib.error.URLError),
197 ]
198 self._test_urls(urls, self._extra_handlers(), retry=True)
199 finally:
200 os.remove(TESTFN)
201
202 self.assertRaises(ValueError, urllib.request.urlopen,'./relative_path/to/file')
203
204 # XXX Following test depends on machine configurations that are internal
205 # to CNRI. Need to set up a public server with the right authentication

Callers

nothing calls this directly

Calls 8

_test_urlsMethod · 0.95
_extra_handlersMethod · 0.95
openFunction · 0.50
writeMethod · 0.45
closeMethod · 0.45
abspathMethod · 0.45
removeMethod · 0.45
assertRaisesMethod · 0.45

Tested by

no test coverage detected