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

Add an assertNoLogs context manager to unittest TestCase #83566

Closed
kitchoi mannequin opened this issue Jan 18, 2020 · 4 comments
Closed

Add an assertNoLogs context manager to unittest TestCase #83566

kitchoi mannequin opened this issue Jan 18, 2020 · 4 comments
Labels
3.10 only security fixes stdlib Python modules in the Lib dir type-feature A feature request or enhancement

Comments

@kitchoi
Copy link
Mannequin

kitchoi mannequin commented Jan 18, 2020

BPO 39385
Nosy @vsajip, @mdickinson, @rbtcollins, @ezio-melotti, @voidspace, @kitchoi, @francoisfreitag, @remilapeyre, @tirkarthi
PRs
  • bpo-39385: Add an assertNoLogs context manager to unittest.TestCase (GH-18067) #18067
  • bpo-39385: Add missing what's new entry for TestCase.assertNoLogs #22317
  • 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 2020-07-01.21:09:42.076>
    created_at = <Date 2020-01-18.20:25:23.335>
    labels = ['type-feature', 'library', '3.10']
    title = 'Add an assertNoLogs context manager to unittest TestCase'
    updated_at = <Date 2020-09-19.09:32:42.441>
    user = 'https://github.com/kitchoi'

    bugs.python.org fields:

    activity = <Date 2020-09-19.09:32:42.441>
    actor = 'mark.dickinson'
    assignee = 'none'
    closed = True
    closed_date = <Date 2020-07-01.21:09:42.076>
    closer = 'vinay.sajip'
    components = ['Library (Lib)']
    creation = <Date 2020-01-18.20:25:23.335>
    creator = 'Kit Yan Choi'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 39385
    keywords = ['patch']
    message_count = 4.0
    messages = ['360250', '367129', '367134', '372794']
    nosy_count = 9.0
    nosy_names = ['vinay.sajip', 'mark.dickinson', 'rbcollins', 'ezio.melotti', 'michael.foord', 'Kit Yan Choi', 'francois.freitag', 'remi.lapeyre', 'xtreak']
    pr_nums = ['18067', '22317']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue39385'
    versions = ['Python 3.10']

    @kitchoi
    Copy link
    Mannequin Author

    kitchoi mannequin commented Jan 18, 2020

    assertLogs is really useful (bpo-18937). Unfortunately it does not cover the use cases where one wants to ensure no logs are emitted.

    Similar to assertLogs, we can have a context manager for asserting no logs, something like this?:

    with assertNoLogs(logger, level):
        ...

    If logs are unexpected found, the test would fail with the logs captured included in the error message.

    Happy to submit a PR if there is interest.

    @kitchoi kitchoi mannequin added stdlib Python modules in the Lib dir type-feature A feature request or enhancement labels Jan 18, 2020
    @SilentGhost SilentGhost mannequin added 3.9 only security fixes labels Jan 19, 2020
    @remilapeyre
    Copy link
    Mannequin

    remilapeyre mannequin commented Apr 23, 2020

    This makes sense, should assertNoWarns() be added too?

    @kitchoi
    Copy link
    Mannequin Author

    kitchoi mannequin commented Apr 23, 2020

    Thank you for looking into this.
    Yes, I agree it makes sense to have assertNoWarns for the same reason.

    @remilapeyre remilapeyre mannequin added 3.10 only security fixes and removed 3.9 only security fixes labels Jun 10, 2020
    @vsajip
    Copy link
    Member

    vsajip commented Jul 1, 2020

    New changeset 6b34d7b by Kit Choi in branch 'master':
    bpo-39385: Add an assertNoLogs context manager to unittest.TestCase (GH-18067)
    6b34d7b

    @vsajip vsajip closed this as completed Jul 1, 2020
    @vsajip vsajip closed this as completed Jul 1, 2020
    @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
    3.10 only security fixes stdlib Python modules in the Lib dir type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant