Beispiel #1
0
 def test_healing_no_actions(self):
     context = Context()
     length = len(context.dicts)
     with healed_context(context) as ctx:
         pass
     new_length = len(context.dicts)
     self.assertEqual(length, new_length)
     if is_django_15plus():
         self.assertIn('True', context)
         self.assertIn('False', context)
         self.assertIn('None', context)
Beispiel #2
0
 def test_healing_via_dict(self):
     context = {'1': 2}
     with healed_context(context) as ctx:
         ctx.update({'3': 4})
         if is_django_15plus():
             self.assertEqual(len(ctx.dicts), 3)
             self.assertEqual(ctx.dicts, [
                 {'True': True, 'False': False, 'None': None},
                 {'1': 2},
                 {'3': 4},
             ])
     self.assertEqual(len(context), 1)
     self.assertEqual(context, {'1': 2})
Beispiel #3
0
 def test_healing_prefilled(self):
     context = Context({'b': 2})
     length = len(context.dicts)
     with healed_context(context) as ctx:
         ctx.update({'a': 1})
     new_length = len(context.dicts)
     self.assertEqual(length, new_length)
     if is_django_15plus():
         self.assertIn('True', context)
         self.assertIn('False', context)
         self.assertIn('None', context)
     self.assertIn('b', context)
     self.assertNotIn('a', context)
 def test_none_content_object_debug(self):
     """ in debug, error loudly to the user """
     tmpl = Template("""
     output:
     {% load editregion %}
     {% editregion "test" None %}fallback{% endeditregion %}
     """)
     if is_django_15plus():
         with self.assertRaisesRegexp(ImproperlyConfigured,
                                      'no object provided to the "editregion" '
                                      'template tag forregion "test"'):
             tmpl.render(Context()).strip()
     else:
         with self.assertRaisesRegexp(ValueError,
                                      "content_object was probably '', "
                                      "check the context provided"):
             tmpl.render(Context()).strip()
Beispiel #5
0
 def test_healing(self):
     context = Context()
     length = len(context.dicts)
     with healed_context(context) as ctx:
         ctx.update({'a': 1})
         ctx.update({'b': 2})
         ctx.update({'c': 3})
     new_length = len(context.dicts)
     self.assertEqual(length, new_length)
     # 1.4 didn't hardcode an initial dict for special values.
     if is_django_15plus():
         self.assertIn('True', context)
         self.assertIn('False', context)
         self.assertIn('None', context)
     self.assertNotIn('b', context)
     is_same = Context()
     # comparing Context() to Context() doesn't work ;|
     self.assertEqual(is_same.dicts, context.dicts)
 def test_is_less_than_15(self):
     self.assertFalse(is_django_15plus())
 def test_is_at_least_15(self):
     self.assertTrue(is_django_15plus())