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

TestLoader.loadTestsFromName does not use suiteClass attribute to create TestSuite instances #51115

Closed
MarkRoddy mannequin opened this issue Sep 8, 2009 · 4 comments
Closed
Assignees
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@MarkRoddy
Copy link
Mannequin

MarkRoddy mannequin commented Sep 8, 2009

BPO 6866
Nosy @bitdancer, @voidspace
Files
  • unittest.patch: patch for unittest.py to correct observed behavior and two tests fixtures that check for desired behavior
  • unittest.trunk.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 = 'https://github.com/voidspace'
    closed_at = <Date 2009-09-13.17:28:51.822>
    created_at = <Date 2009-09-08.20:03:48.629>
    labels = ['type-bug', 'library']
    title = 'TestLoader.loadTestsFromName does not use suiteClass attribute to create TestSuite instances'
    updated_at = <Date 2009-09-13.17:28:51.821>
    user = 'https://bugs.python.org/MarkRoddy'

    bugs.python.org fields:

    activity = <Date 2009-09-13.17:28:51.821>
    actor = 'michael.foord'
    assignee = 'michael.foord'
    closed = True
    closed_date = <Date 2009-09-13.17:28:51.822>
    closer = 'michael.foord'
    components = ['Library (Lib)']
    creation = <Date 2009-09-08.20:03:48.629>
    creator = 'MarkRoddy'
    dependencies = []
    files = ['14864', '14865']
    hgrepos = []
    issue_num = 6866
    keywords = ['patch']
    message_count = 4.0
    messages = ['92427', '92430', '92433', '92575']
    nosy_count = 3.0
    nosy_names = ['r.david.murray', 'michael.foord', 'MarkRoddy']
    pr_nums = []
    priority = 'normal'
    resolution = 'accepted'
    stage = 'patch review'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue6866'
    versions = ['Python 2.6', 'Python 3.1', 'Python 2.7', 'Python 3.2']

    @MarkRoddy
    Copy link
    Mannequin Author

    MarkRoddy mannequin commented Sep 8, 2009

    The TestLoader class in unittest.py has an attribute 'suiteClass' that
    is used to create instances of TestSuite object(s) in the process of
    loading tests. If it is desired to subclass the TestSuite class then
    consumers may set this attribute on a TestLoader object in order to
    override what TestSuite class gets instantiated (a pythonic version of
    the factory method pattern).

    However, the loadTestsFromName() on the TestLoader class does not use
    this attribute to create TestSuite instances, and instead has a hard
    coded reference to the unittest.TestSuite class. This results in the
    base class being created instead of a possibly desired subclass that
    has been specified via this attribute.

    Solution for this issue is to change the loadTestsFromName() method to
    use the suiteClass attribute when creating TestSuite objects instead
    using a reference to the TestSuite class. Included is a patch that
    implements this behavior as well as two additional test for the
    test_unittest.py file which expose this issue if run against an
    unpatched version of unittest.

    @MarkRoddy MarkRoddy mannequin added stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Sep 8, 2009
    @bitdancer
    Copy link
    Member

    I haven't run the tests, but a quick glance at the code makes me think
    this is still probably an issue in 2.7/3.1.

    @MarkRoddy
    Copy link
    Mannequin Author

    MarkRoddy mannequin commented Sep 8, 2009

    The issue appears to be in the other versions mentioned from manual
    inspection.

    Also adding another patch as unittest in the trunk has been broken
    apart into a package with several modules so the original patch will
    not work there.

    @voidspace
    Copy link
    Contributor

    Committed revision 74783.

    @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
    stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants