1+ try :
2+ from http .server import BaseHTTPRequestHandler
3+ except ImportError :
4+ from BaseHTTPServer import BaseHTTPRequestHandler
5+
16import pytest
2- from BaseHTTPServer import BaseHTTPRequestHandler
37
48from dvc .config import ConfigError
5- from dvc .exceptions import HTTPErrorStatusCodeException
9+ from dvc .exceptions import HTTPError
610from dvc .path_info import URLInfo
711from dvc .remote .http import RemoteHTTP
812from tests .utils .httpd import StaticFileServer
@@ -19,21 +23,17 @@ def test_no_traverse_compatibility(dvc_repo):
1923 RemoteHTTP (dvc_repo , config )
2024
2125
22- @pytest .mark .parametrize ("response_code" , [404 , 403 , 500 ])
23- def test_download_fails_on_error_code (response_code , dvc_repo ):
26+ def test_download_fails_on_error_code (dvc_repo ):
2427 class ErrorStatusRequestHandler (BaseHTTPRequestHandler ):
2528 def do_GET (self ):
26- self .send_response (response_code , message = "Error message " )
29+ self .send_response (404 , message = "Not found " )
2730 self .end_headers ()
2831
2932 with StaticFileServer (ErrorStatusRequestHandler ) as httpd :
3033 url = "http://localhost:{}/" .format (httpd .server_port )
3134 config = {"url" : url }
3235
3336 remote = RemoteHTTP (dvc_repo , config )
34- import os
3537
36- with pytest .raises (HTTPErrorStatusCodeException ):
37- remote ._download (
38- URLInfo (os .path .join (url , "file.txt" )), "file.txt"
39- )
38+ with pytest .raises (HTTPError ):
39+ remote ._download (URLInfo (url ) / "file.txt" , "file.txt" )
0 commit comments