bpo-34711: Return HTTPStatus.NOT_FOUND if path.endswith(/) and not a directory#9687
Conversation
|
Would you add a unit test? |
|
I do not understand the question. This PR is to allow an existing test to pass in unique situations - rather than code exceptions in the test. Issue17324: -- see https://bugs.python.org/issue17324#msg183247 says, literally:
My current understanding is that the goal is to bring the existing "unit test" test_httpservers and Lib/http/server.py into sync with the quote above. It is know "known" that Windows, under certain conditions, and AIX (always) will return a filename ending in "/" as "OK" rather than as "NOT_FOUND". However, if you could explain what you feel is missing perhaps this could be expanded with another unit test. |
|
You are adding a new code to fix a bug. |
Well, since you can think of it, I guess you are much smarter than I. I can not figure out how to test this in a way it is not already being tested. In the test I am "adding this code for" it tests: and Please help me out with howto test this addition - that is not already tested above? |
|
On 03/10/2018 22:26, Andrew Svetlov wrote:
You are adding a new code to fix a bug.
A test for checking the behavior to never fall into the problem again as a result of some http server refactoring is very desirable.
Hello Andrew,
a) I would gladly write a unittest - but I am confused because the issue
I am correcting is to correct a existing unittest.
b) from the responses to earlier PR's (modify open() so that despite
that some OS accept a trailing slash as a filename - refuse to open a
filename with a trailing slash; b) modify the existing unittest so that
the platform differences are accepted (sometimes trailing slash should
be 404 error, other platforms should be okay). The first was regarding
as too deep, the second as too superficial - and so now the unittest is
left asis because it is specifically for the module and modify the code
so that the premises of the unittest are met.
Please help me out with what you think needs testing - and I'll try to
come up with something/
Sincerely,
Michael
|
|
Which test(s) currently fail(s) on AIX? Can you perhaps supply a link to such failures on a buildbot? Is there a test case for the similar issue with junctions on Windows? I assume not since this would be failing on our Windows CI builds. If this fixes that too, it could be good to add such a test. |
|
On 10/26/2018 4:51 PM, Tal Einat wrote:
Which test(s) currently fail(s) on AIX? Can you perhaps supply a link to such failures on a buildbot?
This is also available on the bots, but rather than having to search in 5000 to 20000 lines of text, here is the issue:
test_all (test.test_httpservers.MiscTestCase) ... ok
======================================================================
FAIL: test_get (test.test_httpservers.SimpleHTTPServerTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/data/prj/python/git/python3-3.8/Lib/test/test_httpservers.py", line 422, in test_get
self.check_status_and_reason(response, HTTPStatus.NOT_FOUND)
File "/data/prj/python/git/python3-3.8/Lib/test/test_httpservers.py", line 374, in check_status_and_reason
self.assertEqual(response.status, status)
AssertionError: 200 != <HTTPStatus.NOT_FOUND: 404>
======================================================================
FAIL: test_path_without_leading_slash (test.test_httpservers.SimpleHTTPServerTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/data/prj/python/git/python3-3.8/Lib/test/test_httpservers.py", line 523, in test_path_without_leading_slash
self.check_status_and_reason(response, HTTPStatus.NOT_FOUND)
File "/data/prj/python/git/python3-3.8/Lib/test/test_httpservers.py", line 374, in check_status_and_reason
self.assertEqual(response.status, status)
AssertionError: 200 != <HTTPStatus.NOT_FOUND: 404>
…----------------------------------------------------------------------
Ran 64 tests in 1.779s
FAILED (failures=2, skipped=13)
/data/prj/python/git/python3-3.8/Lib/test/support/__init__.py:1572: ResourceWarning: unclosed <socket.socket [closed] fd=5, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=6>
gc.collect()
test test_httpservers failed
test_httpservers failed
== Tests result: FAILURE ==
1 test failed:
test_httpservers
Total duration: 2 sec 35 ms
Tests result: FAILURE
AIX is not the only platform that will open a file with a trailing slash.
FYI: this is the third solution, as the others were rejected - see PR9360 and PR9675.
Is there a test case for the similar issue with junctions on Windows? I assume not since this would be failing on our Windows CI builds. If this fixes that too, it could be good to add such a test.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.
|
ncoghlan
left a comment
There was a problem hiding this comment.
LGTM, just waiting for the new CI run that was triggered by my rewording of the NEWS entry.
Please provide guidelines on how much, if any comments, to have in Lib/http/server.py.
I assume there is too much now, while my gut says no comments may only make people wonder why this is being done.
https://bugs.python.org/issue34711