Hello,
I am new to unit tests and I am using django.test.TestCase. What I don't
understand, is this situation
class GameWorldTests(TestCase):
def setUp(self):
self.test_world = GameWorld.objects.create(
name='Testing world',
game=GameWorld.GAME_TYPE_XY,
domain='test.xy.com'
)
print self.test_world.settings['world_width']
... some test ...
def test_map_center_coordinates(self):
gw = self.test_world
# (width, height, (center_x, center_y))
world_sizes = (
(10,10, (5,5)),
(13,13, (7,7)),
)
for x,y,val in world_sizes:
gw.settings['world_width'] = x
gw.settings['world_height'] = y
coordinates = gw.map_center_coordinates()
self.assertEqual(coordinates, val)
def test_world_default_settings(self):
"""
Test if new world have default values
"""
gw = self.test_world
for key,value in self.world_default_settings.items():
self.assertEqual(
gw.settings[key],
value,
u'Database value `%s` for key `%s` is not equal to `%s`' %
(
gw.settings[key],
key,
value
)
)
setUp() is called before every test (AFAIK the database is reset to syncdb
state before calling setUP()), world_width is printed.
test_map_center_coordinates() is run and world_width is changed in second
iteration to 13. Then test_world_default_settings() is run but there is no
default value, but the value from test_map_center_coordinates() test - 13.
Why? Should not be there the world_width default value after database
reset and model creation in setUP()?
Kind regards,
Martin
--
You received this message because you are subscribed to the Google Groups "Django
users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.