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

Use specific asserts in optparse test #64753

Closed
serhiy-storchaka opened this issue Feb 7, 2014 · 4 comments
Closed

Use specific asserts in optparse test #64753

serhiy-storchaka opened this issue Feb 7, 2014 · 4 comments
Labels
tests Tests in the Lib/test dir type-feature A feature request or enhancement

Comments

@serhiy-storchaka
Copy link
Member

BPO 20554
Nosy @berkerpeksag, @serhiy-storchaka
PRs
  • bpo-20554: Use specific asserts in optparse test #786
  • Files
  • test_optparse_asserts.patch
  • 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 = None
    closed_at = <Date 2016-05-06.12:16:44.844>
    created_at = <Date 2014-02-07.21:34:19.217>
    labels = ['type-feature', 'tests']
    title = 'Use specific asserts in optparse test'
    updated_at = <Date 2017-03-23.18:35:37.722>
    user = 'https://github.com/serhiy-storchaka'

    bugs.python.org fields:

    activity = <Date 2017-03-23.18:35:37.722>
    actor = 'BreamoreBoy'
    assignee = 'none'
    closed = True
    closed_date = <Date 2016-05-06.12:16:44.844>
    closer = 'serhiy.storchaka'
    components = ['Tests']
    creation = <Date 2014-02-07.21:34:19.217>
    creator = 'serhiy.storchaka'
    dependencies = []
    files = ['33979']
    hgrepos = []
    issue_num = 20554
    keywords = ['patch']
    message_count = 4.0
    messages = ['210560', '221998', '222380', '264969']
    nosy_count = 3.0
    nosy_names = ['berker.peksag', 'paul.j3', 'serhiy.storchaka']
    pr_nums = ['786']
    priority = 'low'
    resolution = 'wont fix'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue20554'
    versions = ['Python 2.7', 'Python 3.3', 'Python 3.4']

    @serhiy-storchaka
    Copy link
    Member Author

    The proposed patch makes argparse and optparse modules tests use more specific asserts. This will provide more useful failure report.

    @serhiy-storchaka serhiy-storchaka added tests Tests in the Lib/test dir type-feature A feature request or enhancement labels Feb 7, 2014
    @berkerpeksag
    Copy link
    Member

    diff -r 3b94a4ef244e Lib/test/test_argparse.py
    --- a/Lib/test/test_argparse.py	Fri Feb 07 17:53:13 2014 +0100
    +++ b/Lib/test/test_argparse.py	Fri Feb 07 22:34:13 2014 +0200
    @@ -4219,7 +4219,7 @@
                 e = sys.exc_info()[1]
                 expected = 'unknown action'
                 msg = 'expected %r, found %r' % (expected, e)
    -            self.assertTrue(expected in str(e), msg)
    +            self.assertIn(expected, str(e), msg)

    The patch in bpo-9554 replaces this code with assertRaises and assertRegex (I will change the code to use assertRaisesRegex).

    @berkerpeksag berkerpeksag changed the title Use specific asserts in argparse and optparse tests Use specific asserts in optparse test Jul 1, 2014
    @BreamoreBoy
    Copy link
    Mannequin

    BreamoreBoy mannequin commented Jul 5, 2014

    I don't object to these changes but I don't see much sense in them as optparse has been deprecated since 2.7/3.2.

    @berkerpeksag
    Copy link
    Member

    The patch looks simple, but I don't see much gain to apply it since optparse is a deprecated module. I'm in favor of closing this as 'wont fix'.

    @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

    2 participants