Exemplo n.º 1
0
 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)
Exemplo n.º 2
0
 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)
Exemplo n.º 3
0
    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')
Exemplo n.º 4
0
    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)
Exemplo n.º 5
0
    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)