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

Attempt to further increase test coverage of calendar module #69714

Closed
RohitMediratta mannequin opened this issue Nov 1, 2015 · 10 comments · Fixed by #93655
Closed

Attempt to further increase test coverage of calendar module #69714

RohitMediratta mannequin opened this issue Nov 1, 2015 · 10 comments · Fixed by #93655
Labels
tests Tests in the Lib/test dir type-feature A feature request or enhancement

Comments

@RohitMediratta
Copy link
Mannequin

RohitMediratta mannequin commented Nov 1, 2015

BPO 25528
Nosy @rhettinger, @vadmium, @serhiy-storchaka, @matrixise, @iritkatriel
Files
  • mywork.patch: Patch to increase coverage for 3 additional lines
  • mywork_update.patch: Updated patch showing the correct 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 = None
    created_at = <Date 2015-11-01.09:57:43.791>
    labels = ['type-feature', 'tests']
    title = 'Attempt to further increase test coverage of calendar module'
    updated_at = <Date 2022-03-22.21:27:14.499>
    user = 'https://bugs.python.org/RohitMediratta'

    bugs.python.org fields:

    activity = <Date 2022-03-22.21:27:14.499>
    actor = 'iritkatriel'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = ['Tests']
    creation = <Date 2015-11-01.09:57:43.791>
    creator = 'Rohit Mediratta'
    dependencies = []
    files = ['40916', '41109']
    hgrepos = []
    issue_num = 25528
    keywords = ['patch']
    message_count = 7.0
    messages = ['253836', '254421', '255047', '255416', '255417', '255423', '415815']
    nosy_count = 6.0
    nosy_names = ['rhettinger', 'martin.panter', 'serhiy.storchaka', 'matrixise', 'Rohit Mediratta', 'iritkatriel']
    pr_nums = []
    priority = 'normal'
    resolution = None
    stage = 'patch review'
    status = 'open'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue25528'
    versions = ['Python 3.6']

    Linked PRs

    @RohitMediratta
    Copy link
    Mannequin Author

    RohitMediratta mannequin commented Nov 1, 2015

    Opened to submit a patch.

    • make patchcheck succeeded
    • full testsuite succeeded
    • Old coverage
      Lib/calendar.py 375 54 86% 511, 519, 541, 608-699, 703
    • New coverage
      Lib/calendar.py 375 51 86% 608-699, 703

    @RohitMediratta RohitMediratta mannequin added tests Tests in the Lib/test dir type-feature A feature request or enhancement labels Nov 1, 2015
    @vadmium
    Copy link
    Member

    vadmium commented Nov 9, 2015

    Rohit, it looks like your patch is reversed. The lines with a + sign already exist; are the - lines your proposed additions? Equivalently, revision f7db966c9fee already exists; is fb9d4ccbadf0 your new proposed revision?

    Assuming the patch is reversed, I suggest keeping the locale=None case, perhaps as a separate test case or loop iteration. Otherwise you are throwing out one test case to add another.

    @RohitMediratta
    Copy link
    Mannequin Author

    RohitMediratta mannequin commented Nov 21, 2015

    Thanks for the comments. I did indeed have the patch reversed. I've resolved it here.

    Martin: I had the locale=None case in the patch.

    @matrixise
    Copy link
    Member

    no problem about the second patch of Rohit.

    pass the test with default and I have tested the code in the REPL.

    @serhiy-storchaka
    Copy link
    Member

    The problem with Rohit's patch is that it throws out existing test case.

    @matrixise
    Copy link
    Member

    Sure,

    But the patch is correct.

    Now, you are right, we have to ask him a new patch where the function is really tested.

    @iritkatriel
    Copy link
    Member

    The patch needs to be reviewed. If the tests are still relevant and increase coverage, it needs to be converted to a GitHub PR. Otherwise this issue can be closed.

    See also bpo-13330.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    @AA-Turner
    Copy link
    Member

    This hasn't been converted into a PR, if someone would like to we can re-open this issue in the future.

    A

    @AA-Turner AA-Turner closed this as not planned Won't fix, can't repro, duplicate, stale Jun 3, 2022
    bxsx added a commit to bxsx/cpython that referenced this issue Jun 9, 2022
    bxsx added a commit to bxsx/cpython that referenced this issue Jun 9, 2022
    bxsx added a commit to bxsx/cpython that referenced this issue Jun 9, 2022
    ….Locale{Text|HTML}Calendar`
    
    There are 3 paths to use `locale` argument in
    `calendar.Locale{Text|HTML}Calendar.__init__(..., locale=None)`:
    (1) `locale=None` -- denotes the "default locale"[1]
    (2) `locale=""` -- denotes the native environment
    (3) `locale=other_valid_locale` -- denotes a custom locale
    
    So far case (2) is covered and case (1) is in 78935da (same branch).
    This commit adds a remaining case (3).
    
    [1] In the current implementation, this translates into the following
    approach:
    
    GET current locale
    IF current locale == "C" THEN
      SET current locale TO ""
      GET current locale
    ENDIF
    bxsx added a commit to bxsx/cpython that referenced this issue Jun 9, 2022
    This condition cannot be true. `_locale.setlocale()` from the C module
    raises `locale.Error` instead of returning `None` for
    `different_locale.__enter__` (where `self.oldlocale` is set).
    bxsx added a commit to bxsx/cpython that referenced this issue Jun 9, 2022
    bxsx added a commit to bxsx/cpython that referenced this issue Jun 9, 2022
    bxsx added a commit to bxsx/cpython that referenced this issue Jun 9, 2022
    bxsx added a commit to bxsx/cpython that referenced this issue Jun 9, 2022
    bxsx added a commit to bxsx/cpython that referenced this issue Jun 9, 2022
    @AA-Turner AA-Turner reopened this Jun 9, 2022
    @AA-Turner
    Copy link
    Member

    Reopening as a new PR has appeared (#93655).

    A

    bxsx added a commit to bxsx/cpython that referenced this issue Jun 9, 2022
    bxsx added a commit to bxsx/cpython that referenced this issue Jun 9, 2022
    bxsx added a commit to bxsx/cpython that referenced this issue Jun 9, 2022
    bxsx added a commit to bxsx/cpython that referenced this issue Jun 9, 2022
    … test coverage)""
    
    This reverts commit 40e0da3.
    So it brings back commit a96786c.
    bxsx added a commit to bxsx/cpython that referenced this issue Jun 11, 2022
    No need to process the function.
    This also helps in supporting CLI testing.
    bxsx added a commit to bxsx/cpython that referenced this issue Jun 11, 2022
    bxsx added a commit to bxsx/cpython that referenced this issue Jun 11, 2022
    These tests are now part of `test_illegal_arguments`.
    This reverts commit 238c527.
    bxsx added a commit to bxsx/cpython that referenced this issue Jun 11, 2022
    @terryjreedy
    Copy link
    Member

    @bxsx Please leave the issue number off the commit message for all PR branch commits after the first. It spams the issue with unneeded info that is also on the PR itself.

    bxsx added a commit to bxsx/cpython that referenced this issue Jul 21, 2023
    bxsx added a commit to bxsx/cpython that referenced this issue Jul 21, 2023
    ambv pushed a commit that referenced this issue Jul 22, 2023
    There are 3 paths to use `locale` argument in
    `calendar.Locale{Text|HTML}Calendar.__init__(..., locale=None)`:
    (1) `locale=None` -- denotes the "default locale"[1]
    (2) `locale=""` -- denotes the native environment
    (3) `locale=other_valid_locale` -- denotes a custom locale
    
    So far case (2) is covered and case (1) is in 78935da (same branch).
    This commit adds a remaining case (3).
    
    [1] In the current implementation, this translates into the following
    approach:
    
    GET current locale
    IF current locale == "C" THEN
      SET current locale TO ""
      GET current locale
    ENDIF
    
    * Remove unreachable code (and increase test coverage)
    
    This condition cannot be true. `_locale.setlocale()` from the C module
    raises `locale.Error` instead of returning `None` for
    `different_locale.__enter__` (where `self.oldlocale` is set).
    
    * Expand the try clause to calls to `LocaleTextCalendar.formatmonthname()`.
    
    This method temporarily changes the current locale to the given locale,
    so `_locale.setlocale()` may raise `local.Error`.
    
    
    Co-authored-by: Rohit Mediratta <[email protected]>
    Co-authored-by: Jessica McKellar <[email protected]>
    Co-authored-by: Adam Turner <[email protected]>
    Co-authored-by: Irit Katriel <[email protected]>
    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

    Successfully merging a pull request may close this issue.

    6 participants