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

Deprecate obsolete functions in unittest #50096

Closed
voidspace opened this issue Apr 25, 2009 · 14 comments
Closed

Deprecate obsolete functions in unittest #50096

voidspace opened this issue Apr 25, 2009 · 14 comments
Assignees
Labels
3.11 only security fixes stdlib Python modules in the Lib dir type-feature A feature request or enhancement

Comments

@voidspace
Copy link
Contributor

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']

    @voidspace
    Copy link
    Contributor Author

    _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?

    @voidspace voidspace self-assigned this Apr 25, 2009
    @voidspace voidspace added the stdlib Python modules in the Lib dir label Apr 25, 2009
    @birkenfeld
    Copy link
    Member

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

    @voidspace
    Copy link
    Contributor Author

    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.

    @birkenfeld
    Copy link
    Member

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

    @voidspace
    Copy link
    Contributor Author

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

    @ezio-melotti ezio-melotti added the type-feature A feature request or enhancement label Sep 26, 2012
    @erlend-aasland
    Copy link
    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))

    @serhiy-storchaka
    Copy link
    Member

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

    @ambv
    Copy link
    Contributor

    ambv commented Sep 15, 2021

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

    @serhiy-storchaka
    Copy link
    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.

    @serhiy-storchaka
    Copy link
    Member

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

    @serhiy-storchaka serhiy-storchaka added the 3.11 only security fixes label Sep 17, 2021
    @erlend-aasland
    Copy link
    Contributor

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

    @serhiy-storchaka
    Copy link
    Member

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

    @erlend-aasland
    Copy link
    Contributor

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

    How convenient :)

    @hugovk
    Copy link
    Member

    hugovk commented May 24, 2023

    Please see PR #104836 to remove them in 3.13.

    j4ckofalltrades added a commit to j4ckofalltrades/plus-weather-project-template that referenced this issue Apr 17, 2024
    The `unittest.makeSuite` method has been marked as deprecated since 3.11
    and is slated for removal in 3.13; it is recommended to use the
    `unittest.TestLoader().loadTestsFromTestCase()` method instead.
    
    See python/cpython#50096 for more details.
    j4ckofalltrades added a commit to j4ckofalltrades/plus-weather-project-template that referenced this issue Apr 17, 2024
    The `unittest.makeSuite` method has been marked as deprecated since 3.11
    and is slated for removal in 3.13; it is recommended to use the
    `unittest.TestLoader().loadTestsFromTestCase()` method instead.
    
    See python/cpython#50096 for more details.
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.11 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

    7 participants