-
-
Notifications
You must be signed in to change notification settings - Fork 858
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
Support header comparisons with dict or list. #1326
Support header comparisons with dict or list. #1326
Conversation
@@ -23,7 +23,8 @@ def test_headers(): | |||
assert dict(h) == {"a": "123, 456", "b": "789"} | |||
assert repr(h) == "Headers([('a', '123'), ('a', '456'), ('b', '789')])" | |||
assert h == httpx.Headers([("a", "123"), ("b", "789"), ("a", "456")]) | |||
assert h != [("a", "123"), ("A", "456"), ("b", "789")] | |||
assert h == [("a", "123"), ("A", "456"), ("b", "789")] | |||
assert h == {"a": "123", "A": "456", "b": "789"} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To keep coverage at 100% we'll also need a test against a no-headers-like item.
Eg...
assert h != "a: 123\nA: 456\nb: 789"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, thanks!
There's also several other places in the test cases that could be fixed up too...
$ grep "== httpx.Headers" -r tests -n
tests/models/test_requests.py:29: assert request.headers == httpx.Headers(
tests/models/test_requests.py:39: assert request.headers == httpx.Headers(
tests/models/test_requests.py:52: assert request.headers == httpx.Headers(
tests/models/test_requests.py:76: assert request.headers == httpx.Headers(
tests/models/test_responses.py:47: assert response.headers == httpx.Headers(
tests/models/test_responses.py:60: assert response.headers == httpx.Headers(
tests/models/test_responses.py:74: assert response.headers == httpx.Headers(
tests/models/test_responses.py:88: assert response.headers == httpx.Headers(
tests/models/test_responses.py:745: assert response.headers == httpx.Headers({"Transfer-Encoding": "chunked"})
tests/models/test_responses.py:754: assert response.headers == httpx.Headers({"Content-Length": "8"})
tests/models/test_headers.py:25: assert h == httpx.Headers([("a", "123"), ("b", "789"), ("a", "456")])```
Great, let me fix up. |
.vscode/settings.json
Outdated
@@ -0,0 +1,3 @@ | |||
{ | |||
"python.pythonPath": "/Users/mus/Projects/httpx/venv/bin/python3" | |||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't really want this file. You might want to setup a global gitignore to avoid including config that's specific to your local dev environment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Slipped me. Fixing.
Fantastic stuff! 💚 |
I see my master is behind. Let me ff. |
Oh you did it. perfect! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ace!
Allows comparison of headers with dict or list:
Closes #1325