def test_ensure_url_secure_code(): url = ensure_url("s = 'toto/toto.txt'", 'code') assert url.scheme == 'code' assert url.path == "s = 'toto/toto.txt'"
def test_ensure_url_change_default_scheme(): url = ensure_url("a = 1", 'code') assert url.scheme == 'code' assert url.path == "a = 1"
def test_ensure_url_handle_unknown_scheme(): url = ensure_url("code:dir/file.txt") assert url.scheme == 'code' assert url.netloc == '' assert url.path == "dir/file.txt"
def test_ensure_url_default_scheme_is_file(): url = ensure_url("dir/file.txt") assert url.scheme == 'file' assert url.netloc == '' assert url.path == "dir/file.txt"
def test_ensure_url_parse_url(): url = ensure_url("http://domain.com/dir/file.txt") assert url.scheme == "http" assert url.netloc == "domain.com" assert url.path == "/dir/file.txt"
def test_ensure_url_takes_both_str_and_url(): url = ensure_url("http://domain.com/dir/file.txt") url2 = ensure_url(url) assert url == url2