diff --git a/tests/test_url.py b/tests/test_url.py index 3c9499aa..e821ec31 100644 --- a/tests/test_url.py +++ b/tests/test_url.py @@ -4,7 +4,7 @@ import unittest from w3lib.url import (safe_url_string, safe_download_url, url_query_parameter, add_or_replace_parameter, url_query_cleaner, - file_uri_to_path, path_to_file_uri, any_to_uri) + file_uri_to_path, path_to_file_uri, any_to_uri, urljoin_rfc) class UrlTests(unittest.TestCase): @@ -315,6 +315,10 @@ def test_any_to_uri(self): self.assertEqual(any_to_uri("http://www.example.com/some/path.txt"), "http://www.example.com/some/path.txt") + def test_urljoin_rfc_deprecated(self): + jurl = urljoin_rfc("http://www.example.com/", "/test") + self.assertEqual(jurl, b"http://www.example.com/test") + if __name__ == "__main__": unittest.main() diff --git a/w3lib/url.py b/w3lib/url.py index 56c0a950..6c09d79a 100644 --- a/w3lib/url.py +++ b/w3lib/url.py @@ -57,8 +57,8 @@ def urljoin_rfc(base, ref, encoding='utf-8'): warnings.warn("w3lib.url.urljoin_rfc is deprecated, use urlparse.urljoin instead", DeprecationWarning) - str_base = unicode_to_str(base, encoding) - str_ref = unicode_to_str(ref, encoding) + str_base = to_bytes(base, encoding) + str_ref = to_bytes(ref, encoding) return urljoin(str_base, str_ref) _reserved = b';/?:@&=+$|,#' # RFC 3986 (Generic Syntax)