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

fix using unittest as a superclass #46247

Closed
agoucher mannequin opened this issue Jan 28, 2008 · 3 comments
Closed

fix using unittest as a superclass #46247

agoucher mannequin opened this issue Jan 28, 2008 · 3 comments
Labels
stdlib Python modules in the Lib dir

Comments

@agoucher
Copy link
Mannequin

agoucher mannequin commented Jan 28, 2008

BPO 1955
Nosy @gvanrossum, @pitrou
Files
  • cpython-unittest-subclass.diff: cpython-unittest-subclass.diff
  • 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 = <Date 2008-01-28.15:57:32.018>
    created_at = <Date 2008-01-28.14:39:33.412>
    labels = ['library']
    title = 'fix using unittest as a superclass'
    updated_at = <Date 2008-01-28.15:57:31.913>
    user = 'https://bugs.python.org/agoucher'

    bugs.python.org fields:

    activity = <Date 2008-01-28.15:57:31.913>
    actor = 'gvanrossum'
    assignee = 'none'
    closed = True
    closed_date = <Date 2008-01-28.15:57:32.018>
    closer = 'gvanrossum'
    components = ['Library (Lib)']
    creation = <Date 2008-01-28.14:39:33.412>
    creator = 'agoucher'
    dependencies = []
    files = ['9311']
    hgrepos = []
    issue_num = 1955
    keywords = ['patch']
    message_count = 3.0
    messages = ['61776', '61780', '61782']
    nosy_count = 3.0
    nosy_names = ['gvanrossum', 'pitrou', 'agoucher']
    pr_nums = []
    priority = 'normal'
    resolution = 'rejected'
    stage = None
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue1955'
    versions = ['Python 2.5']

    @agoucher
    Copy link
    Mannequin Author

    agoucher mannequin commented Jan 28, 2008

    There are a couple places in unittest where 'issubclass(something,
    TestCase)' is used. This prevents you from organizing your test code via
    class hierarchies. To solve this problem, issubclass should be looking
    whether the object is a subclass of unittest.TestCase to walk the
    inheritance tree all the way up and not just a single level.

    Currently, this will not work.
    module A..
    class A(unittest.TestCase):
    pass

    module B...
    import A

    class B(A.A)
        def testFoo(self):
            print "blah blah blah

    I have attached a patch which will address all locations where this
    could happen.

    @agoucher agoucher mannequin added the stdlib Python modules in the Lib dir label Jan 28, 2008
    @pitrou
    Copy link
    Member

    pitrou commented Jan 28, 2008

    I don't really understand what problem you are trying to solve. Can you
    attach a sample script to show it more clearly?

    Also, the only thing your patch does is rename Test(Case|Suite)
    references to unittest.Test(Case|Suite)... I doubt it would have any
    effect unless you were monkeypatching the unittest module to replace
    those classes with other ones (which should certainly be considered very
    dirty ;-)).

    @gvanrossum
    Copy link
    Member

    This patch seems to be based upon a misunderstanding of how Python
    namespaces work.

    @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
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants