Skip to content

fix using unittest as a superclass #46247

Closed

Description

@agoucher
mannequin
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']

    Activity

    1. agoucher commented on Jan 28, 2008

      agouchermannequin
      MannequinAuthor

      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.

    2. added
      stdlib
      on Jan 28, 2008
    3. pitrou commented on Jan 28, 2008

      @pitrou
      Member

      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 ;-)).

    4. gvanrossum commented on Jan 28, 2008

      @gvanrossum
      Member

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

    5. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      stdlib

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions