Created
October 21, 2014 22:09
-
-
Save ricomoss/5eff9658ae75aa419d88 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyModelA(models.Model): | |
model_b = models.ForeignKey(MyModelB, blank=True, null=True) | |
class MyModelB(models.Model): | |
name = models.CharField(max_length=10) | |
# Fixtureless use case | |
from django.test import TestCase | |
from fixtureless import Factory | |
from my_models import MyModelA, MyModelB | |
class MyTestCase(TestCase): | |
def setUp(self): | |
factory = Factory() | |
self.model_b = factory.create(MyModelB) | |
init_dict = {'model_b': self.model_b} | |
self.model_a = factory.create(MyModelA, init_dict) | |
def test_this(self): | |
self.assertEqual(self.model_a.model_b, self.model_b) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment