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

yarl tests fail with python3.8 #410

Closed
makefu opened this issue Dec 29, 2019 · 8 comments
Closed

yarl tests fail with python3.8 #410

makefu opened this issue Dec 29, 2019 · 8 comments
Labels

Comments

@makefu
Copy link

makefu commented Dec 29, 2019

One python Test is failing with python3.8, is this a global issue or could our distribution skip the tests?

# pytest ./tests ./yarl

platform linux -- Python 3.8.1, pytest-5.2.4, py-1.8.0, pluggy-0.13.1 -- /nix/store/wp9b0dr34gsm785i0w8d3jx888j9gvd4-python3-3.8.1/bin/python3.8
cachedir: .pytest_cache                                                              
rootdir: /build/yarl-1.4.2, inifile: setup.cfg                                   
plugins: cov-2.8.1                                                                   
collected 876 items     

tests/test_cached_property.py::test_reify PASSED                         [  0%]                                                                                                                                                      
...
tests/test_url_parsing.py::TestScheme::test_scheme_only PASSED           [ 88%]                                                                                           
tests/test_url_parsing.py::TestScheme::test_no_scheme1 FAILED            [ 88%]      
tests/test_url_parsing.py::TestScheme::test_no_scheme2 PASSED            [ 88%]      
...
tests/test_url_update_netloc.py::test_with_port_invalid_type PASSED      [100%]Coverage.py warning: No data was collected. (no-data-collected)                            
                                                                                                                                                                          
                                                                                                                                                                          
=================================== FAILURES ===================================                                                                                          
__________________________ TestScheme.test_no_scheme1 __________________________                                                                                          
                                                                                                                                                                          
self = <test_url_parsing.TestScheme object at 0x7ffff5843040>                                                                                                             
                                                                                                                                                                          
    def test_no_scheme1(self):                                                                                                                                            
        u = URL("google.com:80")                                                                                                                                          
>       assert u.scheme == ""                                                                                                                                             
E       AssertionError: assert 'google.com' == ''                                                                                                                         
E         - google.com                                                                                                                                                    
                                                                                                                                                                          
tests/test_url_parsing.py:43: AssertionError                                                                                                                              
                                                                                                                                                                          
----------- coverage: platform linux, python 3.8.1-final-0 -----------                                                                                                    
Name               Stmts   Miss  Cover
--------------------------------------
yarl/__init__.py     498    498     0%
yarl/quoting.py      166    166     0%
--------------------------------------
TOTAL                664    664     0%

=================== 1 failed, 867 passed, 8 xfailed in 2.71s ===================
builder for '/nix/store/ahgd1cmxxlv9k15zj4lj16l2qznxs6s5-python3.8-yarl-1.4.2.drv' failed with exit code 1

The issue seems to exist at least since yarl-1.3.0

We are tracking the issue in NixOS/nixpkgs#75663

@RazerM
Copy link

RazerM commented Jan 6, 2020

@webknjaz webknjaz added the bug label Jan 6, 2020
@webknjaz
Copy link
Member

webknjaz commented Jan 6, 2020

While this is a change in CPython that may be reverted eventually in 3.8.2, it looks like it will persist in the further Python versions (3.9+). So YARL will need a version-dependent patch to properly detect the implementation (maybe feature-detect it) and keep the behavior consistent across versions.

@makefu I suppose you could temporarily add a patch with @pytest.mark.xfail for this test in your distro and then remove it once this issue is resolved.

@webknjaz
Copy link
Member

webknjaz commented Jan 6, 2020

P.S. The current CI is green because it still uses 3.8.0

@hartwork
Copy link

hartwork commented Mar 4, 2020

Python 3.7.6 is affected too.

@hartwork
Copy link

hartwork commented Mar 4, 2020

PS: My patch for Gentoo: yarl-1.4.2-disable-broken-tests.patch.

@Lonami
Copy link
Contributor

Lonami commented Apr 27, 2020

I just cloned the repository (commit 9afd40d) and running pytest showed the following failures, running Python 3.7.4:

test_unquoter_path_with_plus[py_unquoter]
test_user_empty_password
test_with_fragment_None_matching
test_with_fragment_matching
test_build_with_none_path
test_build_with_none_query_string
test_build_with_none_fragment
7 failed, 861 passed, 8 xfailed in 3.72s
Full output
WARNING: Failed to generate report: No data to report.

/home/lonami/.local/lib/python3.7/site-packages/pytest_cov/plugin.py:254: PytestWarning: Failed to generate report: No data to report.

  self.cov_controller.finish()


=================================== FAILURES ===================================
__________________ test_unquoter_path_with_plus[py_unquoter] ___________________

unquoter = <class 'yarl.quoting._Unquoter'>

    def test_unquoter_path_with_plus(unquoter):
        s = "/test/x+y%2Bz/:+%2B/"
>       assert "/test/x+y+z/:++/" == unquoter(unsafe="+")(s)
E       AssertionError: assert '/test/x+y+z/:++/' == '/test/x+y%2Bz/:+%2B/'
E         - /test/x+y+z/:++/
E         ?          ^    ^
E         + /test/x+y%2Bz/:+%2B/
E         ?          ^^^    ^^^

tests/test_quoting.py:367: AssertionError
___________________________ test_user_empty_password ___________________________

    def test_user_empty_password():
        url = URL("http://user:@example.com")
        assert "user" == url.user
>       assert "" == url.password
E       AssertionError: assert '' == None
E         -''
E         +None

tests/test_url.py:150: AssertionError
_______________________ test_with_fragment_None_matching _______________________

    def test_with_fragment_None_matching():
        url = URL("http://example.com/path")
        url2 = url.with_fragment(None)
>       assert url is url2
E       AssertionError: assert URL('http://example.com/path') is URL('http://example.com/path')

tests/test_url.py:674: AssertionError
_________________________ test_with_fragment_matching __________________________

    def test_with_fragment_matching():
        url = URL("http://example.com/path#frag")
        url2 = url.with_fragment("frag")
>       assert url is url2
E       AssertionError: assert URL('http://example.com/path#frag') is URL('http://example.com/path#frag')

tests/test_url.py:680: AssertionError
__________________________ test_build_with_none_path ___________________________

    def test_build_with_none_path():
        with pytest.raises(TypeError):
>           URL.build(scheme="http", host="example.com", path=None)

tests/test_url_build.py:174: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
../../.local/lib/python3.7/site-packages/yarl/__init__.py:215: in build
    path = cls._normalize_path(path)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

cls = <class 'yarl.URL'>, path = None

    @classmethod
    def _normalize_path(cls, path):
        # Drop '.' and '..' from path
    
>       segments = path.split("/")
E       AttributeError: 'NoneType' object has no attribute 'split'

../../.local/lib/python3.7/site-packages/yarl/__init__.py:630: AttributeError
______________________ test_build_with_none_query_string _______________________

    def test_build_with_none_query_string():
        with pytest.raises(TypeError):
>           URL.build(scheme="http", host="example.com", query_string=None)
E           Failed: DID NOT RAISE <class 'TypeError'>

tests/test_url_build.py:179: Failed
________________________ test_build_with_none_fragment _________________________

    def test_build_with_none_fragment():
        with pytest.raises(TypeError):
>           URL.build(scheme="http", host="example.com", fragment=None)
E           Failed: DID NOT RAISE <class 'TypeError'>

tests/test_url_build.py:184: Failed

----------- coverage: platform linux, python 3.7.4-final-0 -----------

=================== 7 failed, 861 passed, 8 xfailed in 3.72s ===================

@mgorny
Copy link
Contributor

mgorny commented Jun 12, 2020

The most relevant upstream bug is: https://bugs.python.org/issue27657

The change was reverted in 3.7 and 3.8. There is still some ongoing discussion whether 3.9 should do it but IMHO the new behavior will stay as it's standards-compliant and results in simpler code. An open question is how to achieve consistency — I suppose someone will eventually create a backport of the new parsing logic.

@asvetlov
Copy link
Member

Fixed by #409

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

No branches or pull requests

7 participants