jazzband / django-waffle

A feature flipper for Django
https://waffle.readthedocs.io
BSD 3-Clause "New" or "Revised" License
1.12k stars 258 forks source link

override_switch in inherited classes should take precedence #482

Open oliveryh opened 1 year ago

oliveryh commented 1 year ago

Hello,

We've been using django-waffle quite a lot, and noticed that inherited child classes aren't able to flip the switch state overridden in a given parent class. This behaviour is the case for django's override_settings and was added around 2013, this means that we often assume django-waffle has the same behaviour. The implementation idea below borrows some similar features.

We've done some work in this commit and will briefly summarise the expected behaviour below:

@override_switch('foo', active=False)
class ParentTestClass(TestCase):
    pass

@override_switch('foo', active=True)
class ChildTestCase(ParentTestCase):

    def test_switch_state(self):
        # I expect this to be true
        self.assertTrue(waffle.switch_is_active('foo'))

What are your thoughts on this addition?