Skip to content

Instantly share code, notes, and snippets.

@inoshiro
Created February 22, 2013 09:01
Show Gist options
  • Save inoshiro/5011910 to your computer and use it in GitHub Desktop.
Save inoshiro/5011910 to your computer and use it in GitHub Desktop.
factory_boyどうやって使うのかいまいち分からない
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