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

Any difference between url and url_obj in URL #1898

Closed
Kilerd opened this issue May 17, 2017 · 2 comments
Closed

Any difference between url and url_obj in URL #1898

Kilerd opened this issue May 17, 2017 · 2 comments
Labels

Comments

@Kilerd
Copy link

Kilerd commented May 17, 2017

just like the demo in official website http://aiohttp.readthedocs.io/en/stable/client.html

async with aiohttp.ClientSession() as session:
    async with session.get('https://api.github.com/events') as resp:
        print(resp.status)
        print(await resp.text())

while the types of resp.url and resp.url_obj are aiohttp.URL instance
it means that assert does not work like this:

assert resp.url == 'http://httpbin.org/get?key2=value2&key1=value1'

in my code while pytesting.
it raise like that:

AssertionError: assert URL('http://127.0.0.1:40404/123') == 'http://127.0.0.1:40404/123'

but, actually, the str of URL is the same as http://127.0.0.1:40404/123

is that any feature instead of? or is it a bug?

@asvetlov
Copy link
Member

In aiohttp 1.1+ ,url pointed to str but .url_obj to URL.
Starting from aiohtp 2.0 they are aliases, .url_obj is deprecated.

Docs should be updated, most likely in the way like this: assert str(resp.url) == 'htpp://....'

@lock
Copy link

lock bot commented Oct 28, 2019

This thread has been automatically locked since there has not been
any recent activity after it was closed. Please open a new issue for
related bugs.

If you feel like there's important points made in this discussion,
please include those exceprts into that new issue.

@lock lock bot added the outdated label Oct 28, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Oct 28, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants