comparison examples/project/zoo/test_race.py @ 5:22ae9aa457af

excercise more bits of the django 1.0b1 test framework
author Victor Ng <victor@monkeybean.ca>
date Thu, 28 Aug 2008 11:29:21 -0400
parents
children
comparison
equal deleted inserted replaced
4:20bca08c0828 5:22ae9aa457af
1 # We have two test classes because we want to induce a race condition
2 # and ensure that the database is always reset between test methods
3
4 from zoo.models import *
5
6 class TestDBRace1(object):
7 def setup(self):
8 assert Zoo.objects.count() == 0
9
10 def test1(self):
11 obj = Zoo.objects.create(name='sample1')
12 assert Zoo.objects.count() == 1
13 assert Zoo.objects.all()[0].name == 'sample1'
14
15
16 class TestDBRace2(object):
17 def setup(self):
18 assert Zoo.objects.count() == 0
19
20 def test1(self):
21 obj = Zoo.objects.create(name='sample2')
22 assert Zoo.objects.count() == 1
23 assert Zoo.objects.all()[0].name == 'sample2'