-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Multiple test failures in tox py34 #278
Comments
I can reproduce the
|
If I change to |
With pdb, I can see that the
|
Good detective work :) It's a bit of a mysterious bug. Any idea what the root cause could be? |
Not sure but I think there's a bug in Python 3.4's HTTP header parsing. Check this out: This in inside
Note that you can see the |
I am suspicious of the
That Also the the value is very short so I suspect that parsing is failing midway through and messing up the processing of all subsequent headers. |
I'm pretty sure that it's choking somewhere in There's even a "defect" recorded. The email parser mentions in its comments that it doesn't throw exceptions, it records defects instead.
It's dubious of whether that |
Oh I guess the test is putting the |
Yea, that's the reason behind the header. Interestingly it only fails within a session, but not when tested outside one like here: https://github.com/jakubroztocil/httpie/blob/04819577154fc1b11fc20ae7ac584d67614eca25/tests/test_unicode.py#L12 |
I am finding a lot of info online that says that you can only use ISO-8859-1 in HTTP headers. So UTF-8 could very well be breaking things. |
Maybe |
So based on your findings the root cause seems to be that the code in
|
I suspect one of the bytes in your unicode data is just plain confusing to the parser. You should check the bytes after they've been encoded |
From http://www.w3.org/Protocols/rfc2616/rfc2616-sec2.html#sec2.2 The TEXT rule is only used for descriptive field contents and values that are not intended to be interpreted by the message parser. Words of *TEXT MAY contain characters from character sets other than ISO- 8859-1 [22] only when encoded according to the rules of RFC 2047 [14]. |
I wonder if it's been failing to parse that Unicode header in all Python versions but you only see the test failure in Python 3 because of the hash randomization causing it to not get the Authorization So perhaps if that test is kept, it needs to be beefed up to more stringently check the |
Here is what gets received, just before parsing:
From a glance it doesn't look like it's RFC 2047. It looks like it's straight UTF-8:
That seems incorrect. |
Reproducing the core problem very simply in an IPython session:
Perhaps most interesting is that midway through the value of
|
Strangely, if I manually construct the header, things seem to work better:
Note how in this case, It is curious that I was able to call |
instead of using UTF-8, which doesn't seem to be legal. See httpie#278
The See: #281 -- tests are failing though. I cc'd flufl @warsaw, because he has his name on a lot of the stdlib code for email and HTTP header parsing. |
So I've mostly focused on Cc: @kevin1024 |
This test is actually failing for me at least part of the time on py34. This was inspired by a bug in httpie: httpie/cli#278 (comment)
I reproduced test failures in kevin1024/pytest-httpbin#13 |
Using a pytest-httpbin with the fix in kevin1024/pytest-httpbin#16 seems to help. Observe:
Wow, I should've split this into 2 issues:
Maybe I'll go ahead and create 2 separate issues for these and keep this around as a master issue to track those two sub-issues. |
OK, created two separate issues:
|
OK, #283 seems to be fixed by upgrading to pytest-httpbin 0.5.0. So now it's just #282 that needs to be addressed. Personally, I'm pretty busy now and don't see myself having time to work on it in the short-term. |
It looks like this can be closed now. Huge thanks, @msabramo! 👍 |
Multiple test failures in
test_sessions.py
.When I run:
I get 1, 2, or 3 test failures out of the 7 total tests in that module.
More info:
TestSessionFlow.test_session_update
fails with:pdb for above error shows:
TestSessionFlow.test_session_read_only
fails withpdb for above error shows:
TestSession.test_session_unicode
fails with:Pertaining to this last error, there is a comment in the test saying:
In py33 I also see 1 to 2 test failures -- I have not yet observed
TestSession.test_session_unicode
failing on py33.Most of the time, all these tests pass on py27, though I am seeing
test_session_read_only
fail occasionally with:The text was updated successfully, but these errors were encountered: