Commits

James Bennett committed d4ed5b6

Test that callables in extra_context are handled properly.

  • Participants
  • Parent commits 637cb20

Comments (0)

Files changed (2)

File registration/test_urls.py

                        # extra_context_argument.
                        url(r'^activate-extra-context/(?P<activation_key>\w+)/$',
                            activate,
-                           {'extra_context': {'foo': 'bar'}},
+                           {'extra_context': {'foo': 'bar', 'callable': lambda: 'called'}},
                            name='registration_test_activate_extra_context'),
                        (r'', include('registration.backends.default.urls')),
                        # Test the 'register' view with custom template
                        # argument.
                        url(r'^register-extra-context/$',
                            register,
-                           {'extra_context': {'foo': 'bar'}},
+                           {'extra_context': {'foo': 'bar', 'callable': lambda: 'called'}},
                            name='registration_test_register_extra_context'),
                        # Test the 'register' view with custom URL for
                        # closed registration.

File registration/tests/views.py

         """
         response = self.client.get(reverse('registration_test_register_extra_context'))
         self.assertEqual(response.context['foo'], 'bar')
+        # Callables in extra_context are called to obtain the value.
+        self.assertEqual(response.context['callable'], 'called')
 
     def test_registration_disallowed_url(self):
         """
         response = self.client.get(reverse('registration_test_activate_extra_context',
                                            kwargs={'activation_key': 'foo'}))
         self.assertEqual(response.context['foo'], 'bar')
+        # Callables in extra_context are called to obtain the value.
+        self.assertEqual(response.context['callable'], 'called')