I haven't been able to debug why this is happening yet (I spent most of
today narrowing down the problem to a simple test case), but if I create
a new Django project, add a new app to it, change settings.py to have
the appropriate db information (I'm using MySQL), and INSTALLED_APPS
setting, then define these two files:
myapp/models.py
---------------
from django.db import models
class ModelA(models.Model):
pass
myapp/tests.py
--------------
from django.test import TestCase
from myapp.models import ModelA
class MyTestCase(TestCase):
def testBug(self):
ModelA.objects.create()
b = ModelA.objects.get(pk=None) #pk=None shouldn't match anything
self.assert_(b is None, 'Unexpectedly found ModelA with id %s'
% (b.id))
When I run the tests under Django 0.96.3, I get the expected exception:
"DoesNotExist: ModelA matching query does not exist."
However, under Django 1.0, 1.0.1, 1.0.2, and the current trunk (revision
10162 at the time when I tested this), the "ModelA.objects.get(pk=None)"
statement unexpectedly returns the object created by the
"ModelA.objects.create()" on the previous line.
Mike
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---