Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test_odd_urls fails with the recent fixes in urllib.parse #176

Open
mcepl opened this issue Sep 13, 2024 · 1 comment
Open

test_odd_urls fails with the recent fixes in urllib.parse #176

mcepl opened this issue Sep 13, 2024 · 1 comment

Comments

@mcepl
Copy link

mcepl commented Sep 13, 2024

With the current updates tests/test_furl.py::TestFurl::test_odd_urls started to fail:

[   15s] =================================== FAILURES ===================================
[   15s] ____________________________ TestFurl.test_odd_urls ____________________________
[   15s] 
[   15s] self = <test_furl.TestFurl testMethod=test_odd_urls>
[   15s] 
[   15s]     def test_odd_urls(self):
[   15s]         # Empty.
[   15s]         f = furl.furl('')
[   15s]         assert f.username is f.password is None
[   15s]         assert f.scheme is f.host is f.port is f.netloc is None
[   15s]         assert str(f.path) == ''
[   15s]         assert str(f.query) == ''
[   15s]         assert f.args == f.query.params == {}
[   15s]         assert str(f.fragment) == ''
[   15s]         assert f.url == ''
[   15s]     
[   15s]         url = (
[   15s]             "sup://example.com/:@-._~!$&'()*+,=;:@-._~!$&'()*+,=:@-._~!$&'()*+"
[   15s]             ",==?/?:@-._~!$'()*+,;=/?:@-._~!$'()*+,;==#/?:@-._~!$&'()*+,;=")
[   15s]         pathstr = "/:@-._~!$&'()*+,=;:@-._~!$&'()*+,=:@-._~!$&'()*+,=="
[   15s]         querystr = (
[   15s]             quote_plus("/?:@-._~!$'()* ,;") + '=' +
[   15s]             quote_plus("/?:@-._~!$'()* ,;=="))
[   15s]         fragmentstr = quote_plus("/?:@-._~!$&'()* ,;=", '/?&=')
[   15s]         f = furl.furl(url)
[   15s]         assert f.scheme == 'sup'
[   15s]         assert f.host == 'example.com'
[   15s]         assert f.port is None
[   15s]         assert f.netloc == 'example.com'
[   15s]         assert str(f.path) == pathstr
[   15s]         assert str(f.query) == querystr
[   15s]         assert str(f.fragment) == fragmentstr
[   15s]     
[   15s]         # Scheme only.
[   15s]         f = furl.furl('sup://')
[   15s]         assert f.scheme == 'sup'
[   15s]         assert f.host == f.netloc == ''
[   15s]         assert f.port is None
[   15s]         assert str(f.path) == str(f.query) == str(f.fragment) == ''
[   15s]         assert f.args == f.query.params == {}
[   15s]         assert f.url == 'sup://'
[   15s]         f.scheme = None
[   15s]         assert f.scheme is None and f.netloc == '' and f.url == '//'
[   15s]         f.scheme = ''
[   15s]         assert f.scheme == '' and f.netloc == '' and f.url == '://'
[   15s]     
[   15s]         f = furl.furl('sup:')
[   15s]         assert f.scheme == 'sup'
[   15s]         assert f.host is f.port is f.netloc is None
[   15s]         assert str(f.path) == str(f.query) == str(f.fragment) == ''
[   15s]         assert f.args == f.query.params == {}
[   15s]         assert f.url == 'sup:'
[   15s]         f.scheme = None
[   15s]         assert f.url == '' and f.netloc is None
[   15s]         f.scheme = ''
[   15s]         assert f.url == ':' and f.netloc is None
[   15s]     
[   15s]         # Host only.
[   15s]         f = furl.furl().set(host='pumps.meat')
[   15s]         assert f.url == '//pumps.meat' and f.netloc == f.host == 'pumps.meat'
[   15s]         f.host = None
[   15s]         assert f.url == '' and f.host is f.netloc is None
[   15s]         f.host = ''
[   15s]         assert f.url == '//' and f.host == f.netloc == ''
[   15s]     
[   15s]         # Port only.
[   15s]         f = furl.furl()
[   15s]         f.port = 99
[   15s]         assert f.url == '//:99' and f.netloc is not None
[   15s]         f.port = None
[   15s]         assert f.url == '' and f.netloc is None
[   15s]     
[   15s]         if sys.version_info < (3, 12):
[   15s]             # urlparse.urlsplit() treats the first two '//' as the beginning
[   15s]             # of a netloc, even if the netloc is empty.
[   15s]             f = furl.furl('////path')
[   15s]             assert f.netloc == '' and str(f.path) == '//path'
[   15s] >           assert f.url == '////path'
[   15s] E           AssertionError: assert '//////path' == '////path'
[   15s] E             
[   15s] E             - ////path
[   15s] E             + //////path
[   15s] E             ? ++
[   15s] 
[   15s] tests/test_furl.py:1640: AssertionError
[   15s] =========================== short test summary info ============================
[   15s] FAILED tests/test_furl.py::TestFurl::test_odd_urls - AssertionError: assert '...
[   15s] ========================= 1 failed, 77 passed in 4.41s =========================

Complete build log showing all packages used and steps taken to reproduce.

@mcepl
Copy link
Author

mcepl commented Sep 13, 2024

This patch seems to help (but I have no idea whether it is a good way):

---
 tests/test_furl.py |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/tests/test_furl.py
+++ b/tests/test_furl.py
@@ -1637,7 +1637,7 @@ class TestFurl(unittest.TestCase):
             # of a netloc, even if the netloc is empty.
             f = furl.furl('////path')
             assert f.netloc == '' and str(f.path) == '//path'
-            assert f.url == '////path'
+            assert f.url in ('//////path', '////path')
 
         # TODO(grun): Test more odd URLs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant