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

Patch for Additional Test Coverage for urllib.error #61673

Closed
dwoz mannequin opened this issue Mar 18, 2013 · 9 comments
Closed

Patch for Additional Test Coverage for urllib.error #61673

dwoz mannequin opened this issue Mar 18, 2013 · 9 comments
Assignees
Labels
tests Tests in the Lib/test dir type-feature A feature request or enhancement

Comments

@dwoz
Copy link
Mannequin

dwoz mannequin commented Mar 18, 2013

BPO 17471
Nosy @orsenthil
Files
  • patch.diff: Adding test to get 100% coverage in urllib.error.
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = 'https://github.com/orsenthil'
    closed_at = <Date 2013-03-19.20:43:20.382>
    created_at = <Date 2013-03-18.23:38:12.828>
    labels = ['type-feature', 'tests']
    title = 'Patch for Additional Test Coverage for urllib.error'
    updated_at = <Date 2013-03-19.23:49:27.693>
    user = 'https://bugs.python.org/dwoz'

    bugs.python.org fields:

    activity = <Date 2013-03-19.23:49:27.693>
    actor = 'python-dev'
    assignee = 'orsenthil'
    closed = True
    closed_date = <Date 2013-03-19.20:43:20.382>
    closer = 'orsenthil'
    components = ['Tests']
    creation = <Date 2013-03-18.23:38:12.828>
    creator = 'dwoz'
    dependencies = []
    files = ['29465']
    hgrepos = []
    issue_num = 17471
    keywords = ['patch']
    message_count = 9.0
    messages = ['184554', '184555', '184674', '184675', '184678', '184694', '184696', '184701', '184707']
    nosy_count = 3.0
    nosy_names = ['orsenthil', 'python-dev', 'dwoz']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue17471'
    versions = ['Python 3.2', 'Python 3.3', 'Python 3.4']

    @dwoz
    Copy link
    Mannequin Author

    dwoz mannequin commented Mar 18, 2013

    Adding test to get 100% coverage in urllib.error.

    @dwoz dwoz mannequin added tests Tests in the Lib/test dir type-feature A feature request or enhancement labels Mar 18, 2013
    @orsenthil
    Copy link
    Member

    Thanks Daniel. I will commit it.

    @orsenthil orsenthil self-assigned this Mar 18, 2013
    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Mar 19, 2013

    New changeset 33f02ccb5301 by Senthil Kumaran in branch '3.2':
    bpo-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':
    bpo-17471 - merge from 3.2
    http://hg.python.org/cpython/rev/4e59a7fc69c6

    New changeset 21d23fda469f by Senthil Kumaran in branch 'default':
    bpo-17471 - merge from 3.3
    http://hg.python.org/cpython/rev/21d23fda469f

    @orsenthil
    Copy link
    Member

    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.

    @dwoz
    Copy link
    Mannequin Author

    dwoz mannequin commented Mar 19, 2013

    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

    @orsenthil
    Copy link
    Member

    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?

    @dwoz
    Copy link
    Mannequin Author

    dwoz mannequin commented Mar 19, 2013

    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.

    @orsenthil
    Copy link
    Member

    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.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Mar 19, 2013

    New changeset ae9aea1b3546 by Senthil Kumaran in branch '3.2':
    bpo-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':
    bpo-17471 - merge from 3.2
    http://hg.python.org/cpython/rev/8e9cf147fbca

    New changeset 64183c2aa05e by Senthil Kumaran in branch 'default':
    bpo-17471: merge from 3.3
    http://hg.python.org/cpython/rev/64183c2aa05e

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    tests Tests in the Lib/test dir type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant