Skip to content

Commit

Permalink
test_templates: removing with for context manager compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthewEthanTam committed Nov 17, 2024
1 parent 2e92fcd commit 213270a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 18 deletions.
6 changes: 5 additions & 1 deletion waffle/templatetags/waffle_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
from django.http import HttpRequest
from django.template.base import VariableDoesNotExist

from waffle import flag_is_active as waffle_flag_is_active, sample_is_active as waffle_sample_is_active, switch_is_active as waffle_switch_is_active
from waffle import (
flag_is_active as waffle_flag_is_active,
sample_is_active as waffle_sample_is_active,
switch_is_active as waffle_switch_is_active
)
from waffle.views import _generate_waffle_js


Expand Down
32 changes: 15 additions & 17 deletions waffle/tests/test_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,24 +42,22 @@ def test_django_tags(self):
self.assertContains(response, 'switch_is_active off')
self.assertContains(response, 'sample_is_active off')

@override_flag("flag", active=True)
@override_sample("sample", active=True)
@override_switch("switch", active=True)
def test_django_tags_enabled(self):
with (
override_flag("flag", active=True),
override_sample("sample", active=True),
override_switch("switch", active=True)
):
request = get()
response = process_request(request, views.flag_in_django)
self.assertContains(response, 'flag on')
self.assertContains(response, 'switch on')
self.assertContains(response, 'sample on')
self.assertNotContains(response, 'flag off')
self.assertNotContains(response, 'switch off')
self.assertNotContains(response, 'sample off')
self.assertContains(response, 'window.waffle =')
self.assertContains(response, 'flag_is_active on')
self.assertContains(response, 'switch_is_active on')
self.assertContains(response, 'sample_is_active on')
request = get()
response = process_request(request, views.flag_in_django)
self.assertContains(response, 'flag on')
self.assertContains(response, 'switch on')
self.assertContains(response, 'sample on')
self.assertNotContains(response, 'flag off')
self.assertNotContains(response, 'switch off')
self.assertNotContains(response, 'sample off')
self.assertContains(response, 'window.waffle =')
self.assertContains(response, 'flag_is_active on')
self.assertContains(response, 'switch_is_active on')
self.assertContains(response, 'sample_is_active on')

def test_get_nodes_by_type(self):
"""WaffleNode.get_nodes_by_type() should find all child nodes."""
Expand Down

0 comments on commit 213270a

Please sign in to comment.