Login

Snippets by nfg

Snippet List

Testrunner with testmodels

I miss the ability to use testmodels in app-tests. Using this testrunner you can include a test "app" in the app's tests module. Say if you have a module test_app.models within the tests module you could use it in the test like this: from django.test import TestCase from some_django_app.tests.test_app import models as testingmodels TEST_APPS = 'test_app' class ATestCase(TestCase): def test_no_url_model_signals(self): thing = testingmodels.ThingModel(name=u'a small thing') `TEST_APPS` can either be a string, a list or a tuple. This testrunner works with Django 1.1. It is based on the simple testrunner included with Django.

  • models
  • testrunner
Read More
Author: nfg
  • 0
  • 0

Template range loop

This tag is meant to mimic the python use of range in a for-loop: 'for i in range(start, end, step)'. It is implemented like a loop and it takes both variable names from the context and constant integers as arguments. Syntax: {% range end as i %} {{ i }} {% endrange %} {% range start:end as i %} {{ i }} {% endrange %} {% range start:step:end as i %} {{ i }} {% endrange %}

  • template
  • range
  • loop
Read More
Author: nfg
  • 0
  • 0

nfg has posted 2 snippets.