old_contents: # -*- coding: utf-8 -*-
  from decimal import Decimal as D
  
  from django.utils import translation
  from django.test import TestCase
  from django import template
  
  
  def render(template_string, ctx):
      tpl = template.Template(template_string)
      return tpl.render(template.Context(ctx))
  
  
  class TestCurrencyFilter(TestCase):
  
      def setUp(self):
          self.template = template.Template(
              "{% load currency_filters %}"
              "{{ price|currency }}"
          )
  
      def test_renders_price_correctly(self):
          out = self.template.render(template.Context({
              'price': D('10.23'),
          }))
          self.assertTrue(u'£10.23' in out)
  
      def test_handles_none_price_gracefully(self):
          self.template.render(template.Context({
              'price': None
          }))
  
      def test_handles_string_price_gracefully(self):
          self.template.render(template.Context({
              'price': ''
          }))
  
      @translation.override(None, deactivate=True)
      def test_handles_no_translation(self):
          self.template.render(template.Context({
              'price': D('10.23'),
          }))
new_contents: # -*- coding: utf-8 -*-
  from decimal import Decimal as D
  
  from django.utils import translation
  from django.test import TestCase
  from django import template
  
  
  def render(template_string, ctx):
      tpl = template.Template(template_string)
      return tpl.render(template.Context(ctx))
  
  
  class TestCurrencyFilter(TestCase):
  
      def setUp(self):
          self.template = template.Template(
              "{% load currency_filters %}"
              "{{ price|currency }}"
          )
  
      def test_renders_price_correctly(self):
          out = self.template.render(template.Context({
              'price': D('10.23'),
          }))
          self.assertTrue(u'£10.23' in out)
  
      def test_handles_none_price_gracefully(self):
          self.template.render(template.Context({
              'price': None
          }))
  
      def test_handles_string_price_gracefully(self):
          self.template.render(template.Context({
              'price': ''
          }))
  
      def test_handles_no_translation(self):
          with translation.override(None, deactivate=True):
              self.template.render(template.Context({
                  'price': D('10.23'),
              }))
subject: Use translation.override as a context manager instead of a decorator.