Created
February 22, 2013 09:01
-
-
Save inoshiro/5011910 to your computer and use it in GitHub Desktop.
factory_boyどうやって使うのかいまいち分からない
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
from django.test import TestCase | |
from . import models | |
import factory | |
class PollFactory(factory.Factory): | |
FACTORY_FOR = models.Poll | |
question = "What's up?" | |
pub_date = '2013-02-22' | |
class FactoryBoyTest(TestCase): | |
def test_factory(self): | |
poll = PollFactory.create() | |
choice = models.Choice( | |
poll=models.Poll.objects.get(id=poll.id), | |
choice="hoge", | |
votes=1) | |
self.assertEqual(choice.poll.question, "What's up?") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment