Skip to content

Deprecate obsolete functions in unittest #50096

Closed

Description

@voidspace
BPO 5846
Nosy @birkenfeld, @ezio-melotti, @voidspace, @ambv, @serhiy-storchaka, @erlend-aasland
PRs
  • bpo-5846: Deprecate obsolete methods makeSuite, findTestCases, and getTestCaseNames in unittest #20400
  • bpo-5846: Deprecate obsolete methods in unittest #28299
  • bpo-5846: Do not use obsolete unittest functions. #28303
  • bpo-5846: Fix deprecations for obsolete unittest functions and add tests. #28382
  • 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 = 'https://github.com/voidspace'
    closed_at = <Date 2021-09-17.09:11:48.612>
    created_at = <Date 2009-04-25.23:44:59.267>
    labels = ['type-feature', 'library', '3.11']
    title = 'Deprecate obsolete functions in unittest'
    updated_at = <Date 2021-09-18.12:12:58.564>
    user = 'https://github.com/voidspace'

    bugs.python.org fields:

    activity = <Date 2021-09-18.12:12:58.564>
    actor = 'erlendaasland'
    assignee = 'michael.foord'
    closed = True
    closed_date = <Date 2021-09-17.09:11:48.612>
    closer = 'serhiy.storchaka'
    components = ['Library (Lib)']
    creation = <Date 2009-04-25.23:44:59.267>
    creator = 'michael.foord'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 5846
    keywords = ['patch']
    message_count = 13.0
    messages = ['86574', '86687', '87298', '87361', '87592', '386705', '401691', '401878', '401899', '402014', '402016', '402042', '402126']
    nosy_count = 6.0
    nosy_names = ['georg.brandl', 'ezio.melotti', 'michael.foord', 'lukasz.langa', 'serhiy.storchaka', 'erlendaasland']
    pr_nums = ['20400', '28299', '28303', '28382']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue5846'
    versions = ['Python 3.11']

    Activity

    1. voidspace commented on Apr 25, 2009

      @voidspace
      ContributorAuthor

      _makeLoader, getTestCaseNames, makeSuite and findTestCases have all had
      the comment "these functions should be considered obsolete" for a long time.

      Is is ok to go straight to deprecation or should they be marked with
      PendingDeprecationWarning first?

    2. self-assigned this
      on Apr 25, 2009
    3. added
      stdlibStandard Library Python modules in the Lib/ directory
      on Apr 25, 2009
    4. birkenfeld commented on Apr 27, 2009

      @birkenfeld
      Member

      I guess adding a standard DeprecationWarning is fine in these cases.

    5. voidspace commented on May 5, 2009

      @voidspace
      ContributorAuthor

      So it turns out that unittest.makeSuite is used about 100 times
      throughout the standard library tests.

      More than half the time it can be replaced with
      unittest.TestLoader().loadTestsFromTestCase(...)

      Some of the other times a loader needs to be constructed and then a
      testMethodPrefix of 'Check' set (yuck!).

      I'm about halfway through a patch that does this. Think it is worth
      continuing or shall I drop it. I don't mind doing it so long as
      *someone* thinks it is worthwhile... :-)

      (I haven't yet checked for getTestCaseNames but I imagine there will be
      a bunch of these to fix as well.)

      Another possibility is to move the functions into test_support
      (deprecating first) where at least they are out of unittest.

    6. birkenfeld commented on May 7, 2009

      @birkenfeld
      Member

      I'm sure Gerhard wouldn't say no to changing the sqlite3 test prefix to
      "test_"...

    7. voidspace commented on May 11, 2009

      @voidspace
      ContributorAuthor

      Hehe - I wasn't actually doing that, just replacing the use of the
      obsolete functions.

    8. erlend-aasland commented on Feb 9, 2021

      @erlend-aasland
      Contributor

      I'm sure Gerhard wouldn't say no to changing the sqlite3 test prefix to
      "test_"...

      FYI, the sqlite3 tests have now been cleaned up (GH-20538).

      Remaining occurrences in Lib/test:
      Lib/test/test_pdb.py: unittest.makeSuite(PdbTestCase),
      Lib/test/test_dbm.py: suites = [unittest.makeSuite(c) for c in classes]
      Lib/test/test_io.py: suite = unittest.TestSuite([unittest.makeSuite(test) for test in tests])
      Lib/test/test_threading_local.py: suite.addTest(unittest.makeSuite(ThreadLocalTest))
      Lib/test/test_threading_local.py: suite.addTest(unittest.makeSuite(PyThreadingLocalTest))
      Lib/test/test_zipimport.py: # item in a list sorted by name, like unittest.makeSuite() does.)
      Lib/test/support/init.py: suite.addTest(unittest.findTestCases(sys.modules[cls]))
      Lib/test/support/init.py: suite.addTest(unittest.makeSuite(cls))
      Lib/test/support/testresult.py: suite.addTest(unittest.makeSuite(TestTests))
      Lib/test/test_email/torture_test.py: suite.addTest(unittest.makeSuite(testclass))
      Lib/test/test_math.py: suite.addTest(unittest.makeSuite(MathTests))
      Lib/test/test_math.py: suite.addTest(unittest.makeSuite(IsCloseTests))

    9. serhiy-storchaka commented on Sep 13, 2021

      @serhiy-storchaka
      Member

      New changeset 851811f by Serhiy Storchaka in branch 'main':
      bpo-5846: Do not use obsolete unittest functions. (GH-28303)
      851811f

    10. ambv commented on Sep 15, 2021

      @ambv
      Contributor

      New changeset ff6d2cc by Erlend Egeberg Aasland in branch 'main':
      bpo-5846: Deprecate obsolete methods in unittest (GH-28299)
      ff6d2cc

    11. serhiy-storchaka commented on Sep 15, 2021

      @serhiy-storchaka
      Member

      I do not think that PR 28299 is correct. We want to deprecate these functions which are implemented in the unittest.loader module, not just names exported to the unittest module.

    12. serhiy-storchaka commented on Sep 17, 2021

      @serhiy-storchaka
      Member

      New changeset b2b035a by Serhiy Storchaka in branch 'main':
      bpo-5846: Fix deprecations for obsolete unittest functions and add tests. (GH-28382)
      b2b035a

    13. erlend-aasland commented on Sep 17, 2021

      @erlend-aasland
      Contributor

      _makeLoader is not deprecated yet, so we might keep this open a little bit more.

    14. serhiy-storchaka commented on Sep 17, 2021

      @serhiy-storchaka
      Member

      It is an internal function. We can remove it without deprecation.

    15. erlend-aasland commented on Sep 18, 2021

      @erlend-aasland
      Contributor

      It is an internal function. We can remove it without deprecation.

      How convenient :)

    16. transferred this issue fromon Apr 10, 2022
    17. hugovk commented on May 24, 2023

      @hugovk
      Member

      Please see PR #104836 to remove them in 3.13.

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    Labels

    3.11only security fixesstdlibStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancement

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions