﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
13016	Invalid ForeignKey ids in fixtures do not cause any error messages	Art <artem.skvira@…>	nobody	"When referencing a non-existing entity instance in fixtures for ForeignKey relationship no error message is thrown in test runner mode (./manage.py test). Please note below how in fixtures instance of Parent contains invalid ID for Child object (2 instead of 1). 
[[BR]]
[[BR]]
This seems to be related to ""always opened transaction"" natures of tests, because if I run ./manage.py testserver data.json I actually get an exception thrown.
[[BR]]
Backend is Postgresql 8.3. 
[[BR]]
[[BR]]
Model:
{{{
  5 class Parent(models.Model):
  6     child = models.ForeignKey('Child')
  7
  8 class Child(models.Model):
  9     name = models.CharField(default='some name', max_length=100)


}}}
[[BR]]
[[BR]]
Fixture (data.json):
{{{
352     {
353         ""pk"": 1,
354         ""model"": ""testapp.parent"",
355         ""fields"": {
356             ""child"": 2
357         }
358     },
359     {
360         ""pk"": 1,
361         ""model"": ""testapp.child"",
362         ""fields"": {
363             ""name"": ""child""
364         }
365     }
}}}
[[BR]]
[[BR]]
Test:
{{{
  5 class SimpleTest(TestCase):
  6
  7     fixtures = ['data.json']
  8
  9     def test_data(self):
 10         self.assertEqual(len(models.Parent.objects.all()), 1)
 11         self.assertEqual(len(models.Child.objects.all()), 1)


}}}


"	Bug	closed	Testing framework	1.1	Normal	duplicate			Accepted	0	0	0	0	0	0
