


"""simple docstring"""







import pytest
import requests

from datasets.utils.file_utils import http_head

from .utils import OfflineSimulationMode, RequestWouldHangIndefinitelyError, offline




@pytest.mark.integration
def   UpperCAmelCase__			():




					'''simple docstring'''


					with offline(OfflineSimulationMode.CONNECTION_TIMES_OUT  ):
										with pytest.raises(UpperCamelCase__  ):
															requests.request("GET"    ,		"https://huggingface.co"  )
										with pytest.raises(requests.exceptions.ConnectTimeout  ):
															requests.request("GET"    ,		"https://huggingface.co"    ,		timeout=1.0  )




@pytest.mark.integration
def   UpperCAmelCase__			():




					'''simple docstring'''


					with offline(OfflineSimulationMode.CONNECTION_FAILS  ):
										with pytest.raises(requests.exceptions.ConnectionError  ):
															requests.request("GET"    ,		"https://huggingface.co"  )




def   UpperCAmelCase__			():




					'''simple docstring'''


					with offline(OfflineSimulationMode.HF_DATASETS_OFFLINE_SET_TO_1  ):
										with pytest.raises(UpperCamelCase__  ):
															http_head("https://huggingface.co"  )




"""simple docstring"""

from typing import Optional
from urllib.parse import quote

import huggingface_hub as hfh
from packaging import version


def lowerCAmelCase_   (					UpperCamelCase__						:			str					, UpperCamelCase__						:			str					, UpperCamelCase__						:			Optional[str] = None			):






 """simple docstring"""







 if version.parse(hfh.__version__			).release < version.parse("""0.11.0"""			).release:
  # old versions of hfh don't url-encode the file path
  __lowercase						=						quote(UpperCamelCase__			)
 return hfh.hf_hub_url(UpperCamelCase__					, UpperCamelCase__					, repo_type="""dataset"""					, revision=UpperCamelCase__			)
