This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Patch for Additional Test Coverage for urllib.error
Type: enhancement Stage: resolved
Components: Tests Versions: Python 3.2, Python 3.3, Python 3.4
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: orsenthil Nosy List: dwoz, orsenthil, python-dev
Priority: normal Keywords: patch

Created on 2013-03-18 23:38 by dwoz, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
patch.diff dwoz, 2013-03-18 23:38 Adding test to get 100% coverage in urllib.error. review
Messages (9)
msg184554 - (view) Author: Daniel Wozniak (dwoz) Date: 2013-03-18 23:38
Adding test to get 100% coverage in urllib.error.
msg184555 - (view) Author: Senthil Kumaran (orsenthil) * (Python committer) Date: 2013-03-18 23:39
Thanks Daniel. I will commit it.
msg184674 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2013-03-19 20:41
New changeset 33f02ccb5301 by Senthil Kumaran in branch '3.2':
#17471 - Improve urllib2 test coverage. Patch contributed by Daniel Wozniak
http://hg.python.org/cpython/rev/33f02ccb5301

New changeset 4e59a7fc69c6 by Senthil Kumaran in branch '3.3':
#17471 - merge from 3.2
http://hg.python.org/cpython/rev/4e59a7fc69c6

New changeset 21d23fda469f by Senthil Kumaran in branch 'default':
#17471 - merge from 3.3
http://hg.python.org/cpython/rev/21d23fda469f
msg184675 - (view) Author: Senthil Kumaran (orsenthil) * (Python committer) Date: 2013-03-19 20:43
Daniel - I could not really get the need for this check.

+    >>> msg = str(err)
+    >>> str(err.code) in msg and err.msg in msg

The other one was really useful and probably covered the reasonstr.

Thanks for the patch.
msg184678 - (view) Author: Daniel Wozniak (dwoz) Date: 2013-03-19 20:52
Senthil,

The two lines you excluded from that patch give us coverage on HTTPError.__str__ , I added to the existing interface test so as not to re-produce the code there. I still think it could be added since it will give us that last line of coverage and verifies the exception's code and msg are in the string representation of HTTPError.

root@d1:/root/hg/cpython# ./python ../coveragepy report --show-missingName               Stmts   Miss  Cover   Missing
------------------------------------------------
Lib/urllib/error      32      1    97%   56
msg184694 - (view) Author: Senthil Kumaran (orsenthil) * (Python committer) Date: 2013-03-19 22:36
Daniel, 

Agree to your point. Sorry that i did not run the coverage before.

I would prefer to do the check this way for readability of the test code and get to 100% coverage.

        >>> expected_errmsg = 'HTTP Error %s: %s' %(err.code, err.msg)
        >>> assert str(err) == expected_errmsg

Any thoughts?
msg184696 - (view) Author: Daniel Wozniak (dwoz) Date: 2013-03-19 22:42
Sure, your way is much easier to tell what is getting tested. The only thing I was trying to avoid is including the static text "HTTP Error" so the test will not break if that static text changes. That said, I really doubt the text would change for any reason. I think we should go with your way.
msg184701 - (view) Author: Senthil Kumaran (orsenthil) * (Python committer) Date: 2013-03-19 23:04
Avoiding the static test is actually a good idea for Exception "messages", as there is no guarantee for those to be consistent across revs. But this one is slightly different in HTTPError str represent and we better be consistent in this. I dont see changing too. Thanks for bringing this to 100% coverage.
msg184707 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2013-03-19 23:49
New changeset ae9aea1b3546 by Senthil Kumaran in branch '3.2':
#17471 - Increasing the urllib.error test coverage. Bringing it to 100%. Based on patch contributed by Daniel Wozniak
http://hg.python.org/cpython/rev/ae9aea1b3546

New changeset 8e9cf147fbca by Senthil Kumaran in branch '3.3':
#17471 - merge from 3.2
http://hg.python.org/cpython/rev/8e9cf147fbca

New changeset 64183c2aa05e by Senthil Kumaran in branch 'default':
#17471: merge from 3.3
http://hg.python.org/cpython/rev/64183c2aa05e
History
Date User Action Args
2022-04-11 14:57:43adminsetgithub: 61673
2013-03-19 23:49:27python-devsetmessages: + msg184707
2013-03-19 23:04:36orsenthilsetmessages: + msg184701
2013-03-19 22:42:36dwozsetmessages: + msg184696
2013-03-19 22:36:36orsenthilsetmessages: + msg184694
2013-03-19 20:52:07dwozsetmessages: + msg184678
2013-03-19 20:43:20orsenthilsetstatus: open -> closed
versions: + Python 3.2, Python 3.3
messages: + msg184675

resolution: fixed
stage: resolved
2013-03-19 20:41:33python-devsetnosy: + python-dev
messages: + msg184674
2013-03-18 23:39:22orsenthilsetassignee: orsenthil

messages: + msg184555
nosy: + orsenthil
2013-03-18 23:38:12dwozcreate