Commits

Matthew Schinckel committed 442b82b

Add coverage support to tox.
Test callable default.

Comments (0)

Files changed (4)

jsonfield/tests/base.py

         obj = BlankJSONFieldTestModel.objects.get()
         self.assertEquals(None, obj.null_json)
         self.assertEquals("", obj.blank_json)
+    
+    def test_callable_default(self):
+        CallableDefaultModel.objects.create()
+        obj = CallableDefaultModel.objects.get()
+        self.assertEquals({'x':2}, obj.json)
+    
+    def test_callable_default_overridden(self):
+        CallableDefaultModel.objects.create(json={'x':3})
+        obj = CallableDefaultModel.objects.get()
+        self.assertEquals({'x':3}, obj.json)

jsonfield/tests/jsonfield_test_app/models.py

     null_json = JSONField(null=True)
     blank_json = JSONField(blank=True)
     class Meta:
+        app_label = 'jsonfield'
+
+class CallableDefaultModel(models.Model):
+    json = JSONField(default=lambda:{'x':2})
+    
+    class Meta:
         app_label = 'jsonfield'
     global_settings.STATIC_ROOT = global_settings.MEDIA_ROOT
     
     global_settings.SECRET_KEY = '334ebe58-a77d-4321-9d01-a7d2cb8d3eea'
+    global_settings.TEST_RUNNER = 'django_coverage.coverage_runner.CoverageRunner'
     
     from django.test.utils import get_runner
     test_runner = get_runner(global_settings)
 [tox]
 envlist = py26,py27,py32,pypy,py27-django-1.4,py27-django-1.5,py27-django-trunk
+
+[base]
+deps=
+  coverage
+  django_coverage
+
 [testenv]
+commands= python setup.py test
 deps=django
-commands= python setup.py test
+  {[base]deps}
+
 [testenv:py27-django-1.4]
 deps= django>=1.4,<1.5
+  {[base]deps}
+
 [testenv:py27-django-1.5]
 deps= django>=1.5,<1.6
+  {[base]deps}
+
 [testenv:py27-django-trunk]
 deps= git+git://github.com/django/django.git
+  {[base]deps}