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 · 13 comments
Closed

Deprecate obsolete functions in unittest #50096

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

Comments

@voidspace
Copy link
Contributor

voidspace commented Apr 25, 2009

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

    voidspace commented Apr 25, 2009

    _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

    birkenfeld commented Apr 27, 2009

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

    @voidspace
    Copy link
    Contributor Author

    voidspace commented May 5, 2009

    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

    birkenfeld commented May 7, 2009

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

    @voidspace
    Copy link
    Contributor Author

    voidspace commented May 11, 2009

    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

    erlend-aasland commented Feb 9, 2021

    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

    serhiy-storchaka commented Sep 13, 2021

    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

    serhiy-storchaka commented Sep 15, 2021

    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

    serhiy-storchaka commented Sep 17, 2021

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

    @erlend-aasland
    Copy link
    Contributor

    erlend-aasland commented Sep 17, 2021

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

    @serhiy-storchaka
    Copy link
    Member

    serhiy-storchaka commented Sep 17, 2021

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

    @erlend-aasland
    Copy link
    Contributor

    erlend-aasland commented Sep 18, 2021

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

    How convenient :)

    @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.11 stdlib Python modules in the Lib dir type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    6 participants