#28869: Django.test.tag Inconsistent Inheritance
-----------------------------------+--------------------------------------
     Reporter:  William Ayd        |                    Owner:  nobody
         Type:  Bug                |                   Status:  new
    Component:  Testing framework  |                  Version:  1.11
     Severity:  Normal             |               Resolution:
     Keywords:  testing, tag       |             Triage Stage:  Unreviewed
    Has patch:  0                  |      Needs documentation:  0
  Needs tests:  0                  |  Patch needs improvement:  0
Easy pickings:  0                  |                    UI/UX:  0
-----------------------------------+--------------------------------------

Comment (by William Ayd):

 Hi Hrishikesh,

 My point was that it's strange that FooBar inherits the tag from it's
 parent while FooBaz does not, simply because the latter adds another tag
 of its own. Either neither class should inherit the tag from its parent,
 or both of them should (I think both inheriting would be preferred).

 From what I see this can be easily fixed changing the tag function in
 Django.tests.util from:

 {{{
 def tag(*tags):
     """
     Decorator to add tags to a test class or method.
     """
     def decorator(obj):
         setattr(obj, 'tags', set(tags))
         return obj
     return decorator
 }}}

 To

 {{{
 def tag(*tags):
     """
     Decorator to add tags to a test class or method.
     """
     def decorator(obj):
         if hasattr(obj, 'tags'):
             obj.tags = obj.tags | set(tags)
         else:
             setattr(obj, 'tags', set(tags))
         return obj
     return decorator
 }}}

 So that subclasses can inherit any existing tags from their parents

-- 
Ticket URL: <https://code.djangoproject.com/ticket/28869#comment:4>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/065.3c2aef869b643bfba8579191c6d1687d%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to