Skip to content

Attempt full test coverage of LocaleTextCalendar.formatweekday #57539

Description

@SeanFleming
BPO 13330
Nosy @rhettinger, @terryjreedy, @berkerpeksag, @serhiy-storchaka, @iritkatriel
Files
  • test_calendar.patch
  • issue13330.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 = None
    created_at = <Date 2011-11-03.06:14:09.978>
    labels = ['easy', 'tests', 'type-feature', 'library', '3.11']
    title = 'Attempt full test coverage of LocaleTextCalendar.formatweekday'
    updated_at = <Date 2022-03-22.21:27:37.691>
    user = 'https://bugs.python.org/SeanFleming'

    bugs.python.org fields:

    activity = <Date 2022-03-22.21:27:37.691>
    actor = 'iritkatriel'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = ['Library (Lib)', 'Tests']
    creation = <Date 2011-11-03.06:14:09.978>
    creator = 'Sean.Fleming'
    dependencies = []
    files = ['23603', '35060']
    hgrepos = []
    issue_num = 13330
    keywords = ['easy']
    message_count = 6.0
    messages = ['146895', '217316', '255419', '255422', '415814', '415816']
    nosy_count = 7.0
    nosy_names = ['rhettinger', 'terry.reedy', 'jesstess', 'berker.peksag', 'Sean.Fleming', 'serhiy.storchaka', 'iritkatriel']
    pr_nums = []
    priority = 'normal'
    resolution = None
    stage = 'patch review'
    status = 'open'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue13330'
    versions = ['Python 3.11']

    Activity

    1. SeanFleming commented on Nov 3, 2011

      SeanFlemingmannequin
      MannequinAuthor

      Patch includes new statements in test_localecalendars of CalendarTestCase such that coverage of LocaleTextCalendar.formatweekday should improve significantly.

      Feedback is appreciated.

    2. added
      stdlibStandard Library Python modules in the Lib/ directory
      type-featureA feature request or enhancement
      on Nov 3, 2011
    3. jesstess commented on Apr 27, 2014

      @jesstess
      Member

      Thanks for working to increase our test coverage, Sean.Fleming!

      Looking at the current coverage, the there is one line in LocaleTextCalendar.formatweekday without coverage: http://hg.python.org/cpython/file/e159cb0d955b/Lib/calendar.py#l519.

      You add some additional tests, but they are mostly testing some very literal aspects of the implementation rather than the purpose of the function. For example:

      + self.assertRaises(IndexError, calendar.LocaleTextCalendar(locale='').formatweekday, 7, 1 )

      It's true that this will raise an IndexError, but formatweekday isn't supposed to be called with these values.

      I've added some tests that add coverage for the line that didn't have coverage, while focusing on the purpose of the function, namely to provide an appropriate day name when constrained to various widths.

      • The patch passes the full test suite
      • The patch passes make patchcheck
      • The patch results in full coverage for LocaleTextCalendar.formatweekday

      Coverage results, before and after:

      $ ./python.exe ../coveragepy/ run --pylib --source=calendar Lib/test/regrtest.py test_calendar
      [1/1] test_calendar
      1 test OK.
      nitefly:cpython jesstess$ ./python.exe ../coveragepy/ report --show-missing
      Name           Stmts   Miss  Cover   Missing

      Lib/calendar 375 54 86% 511, 519, 541, 608-699, 703
      $ patch -p1 < bpo-13330.patch
      patching file Lib/test/test_calendar.py
      patching file Misc/ACKS
      $ ./python.exe ../coveragepy/ run --pylib --source=calendar Lib/test/regrtest.py test_calendar
      [1/1] test_calendar
      1 test OK.
      nitefly:cpython jesstess$ ./python.exe ../coveragepy/ report --show-missing
      Name Stmts Miss Cover Missing
      --------------------------------------------
      Lib/calendar 375 53 86% 511, 541, 608-699, 703

      (519 was the one line without coverage inside LocaleTextCalendar.formatweekday)

    4. serhiy-storchaka commented on Nov 26, 2015

      @serhiy-storchaka
      Member

      The test depends on the en_US locale. Only existing of POSIX locale is guarantied. The test should be skipped instead of failed if the en_US locale is not available. It would be nice to test also with other locales. For example with de_DE, fr_FR, tr_TR, ps_AF - these locales are used also in other tests.

    5. serhiy-storchaka commented on Nov 26, 2015

      @serhiy-storchaka
      Member

      And it looks that only empty locale works on Windows (bpo-21731).

    6. iritkatriel commented on Mar 22, 2022

      @iritkatriel
      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.

    7. iritkatriel commented on Mar 22, 2022

      @iritkatriel
      Member

      See also bpo-25528.

    8. transferred this issue fromon Apr 10, 2022
    9. added
      pendingThe issue will be closed if no feedback is provided
      on May 20, 2022
    10. AA-Turner commented on Jun 3, 2022

      @AA-Turner
      Member

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

      A

    11. removed
      pendingThe issue will be closed if no feedback is provided
      on Jun 3, 2022
    12. added a commit that references this issue on Jun 3, 2022
    13. hugovk commented on Jun 3, 2022

      @hugovk
      Member

      I'll convert it. It might be worth keeping these easy issues open as they're good for new contributors to get started (and linked to from the devguide: https://devguide.python.org/fixingissues/).

    14. reopened this on Jun 3, 2022
    15. added a commit that references this issue on Jun 7, 2022
    16. added 2 commits that reference this issue on Jun 7, 2022
    17. added 2 commits that reference this issue on Jun 7, 2022
    18. added a commit that references this issue on Jun 9, 2022
    19. moved this from Todo to Done in Contribution Queueon Apr 23, 2024
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      3.11only security fixeseasystdlibStandard Library Python modules in the Lib/ directorytestsTests in the Lib/test dirtype-featureA feature request or enhancement

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions