Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Corrects wrong premise on test

  • Loading branch information...
commit 1a5067e86690246c9c4b5832b3b784616aa10452 1 parent f72637d
Bernardo Fontes authored
Showing with 3 additions and 3 deletions.
  1. +1 −1  model_mommy/mommy.py
  2. +2 −2 test/generic/tests/test_mommy.py
View
2  model_mommy/mommy.py
@@ -283,7 +283,7 @@ def _make(self, commit=True, **attrs):
def m2m_value(self, field):
if field.name in self.rel_fields:
return self.generate_value(field)
- if not self.make_m2m:
+ if not self.make_m2m or field.null:
return []
return self.generate_value(field)
View
4 test/generic/tests/test_mommy.py
@@ -212,9 +212,9 @@ def test_does_not_create_nullable_many_to_many_for_relations(self):
classroom = mommy.make(Classroom, make_m2m=False)
self.assertEqual(classroom.students.count(), 0)
- def test_nullable_many_to_many_for_relations_if_flagged(self):
+ def test_nullable_many_to_many_is_not_created_even_if_flagged(self):
classroom = mommy.make(Classroom, make_m2m=True)
- self.assertEqual(classroom.students.count(), 5)
+ self.assertEqual(classroom.students.count(), 0)
def test_simple_creating_person_with_parameters(self):
kid = mommy.make(Person, happy=True, age=10, name='Mike')
Please sign in to comment.
Something went wrong with that request. Please try again.