Skip to content

Commit

Permalink
Merge 3df7389 into a275cf1
Browse files Browse the repository at this point in the history
  • Loading branch information
willbarton committed Jun 2, 2020
2 parents a275cf1 + 3df7389 commit 34a8dba
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 3 additions & 3 deletions flags/middleware.py
@@ -1,5 +1,7 @@
import warnings

from django.core.exceptions import MiddlewareNotUsed


class FlagConditionsMiddleware:
def __init__(self, get_response):
Expand All @@ -8,6 +10,4 @@ def __init__(self, get_response):
"effect. It will be removed in a future version of Django-Flags. ",
FutureWarning,
)

def __call__(self, request):
pass
raise MiddlewareNotUsed
4 changes: 3 additions & 1 deletion flags/tests/test_middleware.py
@@ -1,5 +1,6 @@
import warnings

from django.core.exceptions import MiddlewareNotUsed
from django.test import SimpleTestCase

from flags.middleware import FlagConditionsMiddleware
Expand All @@ -8,7 +9,8 @@
class FlagConditionsMiddlewareTests(SimpleTestCase):
def test_middleware_raises_warning(self):
with warnings.catch_warnings(record=True) as warning_list:
FlagConditionsMiddleware(None)
with self.assertRaises(MiddlewareNotUsed):
FlagConditionsMiddleware(None)

self.assertEqual(len(warning_list), 1)
self.assertEqual(warning_list[0].category, FutureWarning)

0 comments on commit 34a8dba

Please sign in to comment.