Commits

Simon Meers committed 7785187

more and snippets

Comments (0)

Files changed (2)

 More Django Testing Tips
 ========================
 
+RTFM:
+ - https://docs.djangoproject.com/en/dev/topics/testing/
+
 Recommended talks:
  - http://pyvideo.org/video/699/testing-and-django
  - http://pyvideo.org/video/634/speedily-practical-large-scale-tests
 
 Checkout Django's source:
  - https://github.com/django/django/blob/master/django/test/
+ - explore Client and TestCase
+
+Handy things in Django 1.4:
+ - assertRaisesMessage((expected_exception, expected_message)
+ - assertFieldOutput
+ - assertContains(html=True)
+ - assertTemplateUsed as context manager
+ - assertHTMLEqual
+
+Neat stuff inherited from unittest:
+ - http://docs.python.org/library/unittest.html
+ - assertRaisesRegexp, etc
+
+Messing with settings:
+ - with self.settings(FOO='bar'):
+ - @override_settings (django.test.utils)
+ - django.test.signals.setting_changed
 
 Tools to explore:
  - http://nose.readthedocs.org/ -- "is nicer testing for python"
+
+import sys
+import dj_database_url
+
+TESTING = (sys.argv[1:2] == ['test'])
+
+SOUTH_TESTS_MIGRATE = False
+if not TESTING:
+    DATABASES = {
+        'default': dj_database_url.config(
+            default='postgres://localhost'
+        )
+    }