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

unittest.py: Custom TestRunners and --verbose #39053

Closed
mfbarnes mannequin opened this issue Aug 13, 2003 · 3 comments
Closed

unittest.py: Custom TestRunners and --verbose #39053

mfbarnes mannequin opened this issue Aug 13, 2003 · 3 comments
Labels
stdlib Python modules in the Lib dir

Comments

@mfbarnes
Copy link
Mannequin

mfbarnes mannequin commented Aug 13, 2003

BPO 787789
Nosy @birkenfeld
Files
  • unittest.py.diff
  • 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 2007-03-07.09:21:39.000>
    created_at = <Date 2003-08-13.03:31:35.000>
    labels = ['library']
    title = 'unittest.py: Custom TestRunners and --verbose'
    updated_at = <Date 2007-03-07.09:21:39.000>
    user = 'https://bugs.python.org/mfbarnes'

    bugs.python.org fields:

    activity = <Date 2007-03-07.09:21:39.000>
    actor = 'georg.brandl'
    assignee = 'purcell'
    closed = True
    closed_date = None
    closer = None
    components = ['Library (Lib)']
    creation = <Date 2003-08-13.03:31:35.000>
    creator = 'mfbarnes'
    dependencies = []
    files = ['5515']
    hgrepos = []
    issue_num = 787789
    keywords = ['patch']
    message_count = 3.0
    messages = ['44442', '44443', '44444']
    nosy_count = 3.0
    nosy_names = ['georg.brandl', 'purcell', 'mfbarnes']
    pr_nums = []
    priority = 'low'
    resolution = 'accepted'
    stage = None
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue787789'
    versions = ['Python 2.3']

    @mfbarnes
    Copy link
    Mannequin Author

    mfbarnes mannequin commented Aug 13, 2003

    The unittest.TestProgram class accepts a "--verbose"
    command-line argument. But the setting only gets
    applied if the testRunner argument to
    unittest.TestProgram.__init__ is None. There is no
    clean way of creating a custom TestRunner class and
    passing it to unittest.TestProgram such that the
    correct verbosity is picked up.

    This patch slightly alters the interface to
    unittest.TestProgram.__init__ by allowing a class to be
    passed as the testRunner argument (defaulting to
    TextTestRunner instead of None). Then the runTests
    method of unittest.TestProgram checks whether
    self.testRunner is a class, and if so creates an
    instance of it, passing the correct verbosity setting
    to the TestRunner class' __init__ method.

    The patch should still allow a custom TestRunner class
    _instance_ to be passed to unittest.TestProgram.__init__.

    @mfbarnes mfbarnes mannequin closed this as completed Aug 13, 2003
    @mfbarnes mfbarnes mannequin assigned purcell Aug 13, 2003
    @mfbarnes mfbarnes mannequin added the stdlib Python modules in the Lib dir label Aug 13, 2003
    @mfbarnes mfbarnes mannequin closed this as completed Aug 13, 2003
    @mfbarnes mfbarnes mannequin assigned purcell Aug 13, 2003
    @mfbarnes mfbarnes mannequin added the stdlib Python modules in the Lib dir label Aug 13, 2003
    @purcell
    Copy link
    Mannequin

    purcell mannequin commented Sep 10, 2003

    Logged In: YES
    user_id=21477

    I can see your point, but this requres every test runner to accept the
    'verbosity' keyword argument. I'm worried that this will break a large
    number of custom test runners.

    Another approach might be to change TextTestRunner so that 'verbosity'
    is an instance attribute that is set by TestProgram after the test runner
    instance is created. Then existing custom test runners will not break,
    unless they already have a 'verbosity' attribute, which is unlikely.

    I'll bear this patch in mind; I'm looking at a few pending minor changes
    to the module, and this area is one that I'm covering.

    @birkenfeld
    Copy link
    Member

    Thanks for the patch, committed a variant as rev. 54201.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 9, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    stdlib Python modules in the Lib dir
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant