Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8591087
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T23:26:44+00:00 2026-06-11T23:26:44+00:00

Given my model is following: class Author(models.Model): name = models.CharField(max_length=100) description = models.TextField() class

  • 0

Given my model is following:

class Author(models.Model):
    name = models.CharField(max_length=100)
    description = models.TextField()

class Book(models.Model):
    title = models.CharField(max_length=100)
    author = models.ManyToManyField(Author) 

I am using django-dynamic-fixture to generate model fixtures easily for the test. I am also using django_nose which helps me run and manage tests pretty nicely.
Having setup the test_runner in settings.py file and putting all installables at place.

To generate a model as above the test should be

from django_dynamic_fixture import G


class BookModelTest(TestCase):

     def test_book_creation(self):
         author1 = G(Author)
         author2 = G(Author)
         book = G(Book, author=[author1])
         book_obj = Book.objects.all()
         self.assertEquals(book_obj.count(), 1)
         self.assertEquals(list(book_obj[0].author), [author1])
         self.assertEquals(book_obj[0].title, book.title)
         self.assertNotEquals(list(book_obj[0].author), [author1])

    def another_test(self):
       "Here as well i need the same, author1, author2 and book

Also if i write

class AuthorModelTest(TestCase):

   def test_some_stuff()             

I would be needing some fixture value.
So following are the queries i had:

How do i keep my fixture generation DRY. Meaning not creating book and author fixtures from G in each of the functions?

django_nose helps to optimize the setUp and tearDown methods and improves speed, how can I use them here? Just putting *django_nose.FastFixtureTestCase* will take care of setUp tearDown pains? Or do I need to use TransactionTestCase? How do I optimize the above fixture and test?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T23:26:45+00:00Added an answer on June 11, 2026 at 11:26 pm

    TransactionTestCase helps you save an saving an entire DB flush per test, it expects you to start with an unmarred db, you are free to generate it using any fixture generator. TransactionTestCase however leaves the database cluttered, django-nose helps you optimize it. django-nose however has another test runner FastFixtureTestCase helps you optimize the setUp and tearDown.

    As already said, you can use any fixture generation, if you want the goodness of django-nose use the FastFixtureTestCase and it will help you optimize the IO time.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given the following models: class Post(models.Model): title = models.CharField(max_length=200) html = models.TextField() class PostTag(models.Model):
Given the following model: class Project(models.Model): project_name = models.CharField(max_length=255) abstract = models.TextField(blank=True, null=True) full_description
I have the following two models class Author(Model): name = CharField() class Publication(Model): title
I have the following Model: class Group(models.Model): member = models.ManyToManyField(Player, through='GroupMember') name = models.CharField(max_length=20,
I have the following models (details are omitted): class Author(models.Model): name = models.CharField('name', max_length=200,
Given the following models: class Blog(models.Model): name = models.CharField() class Entry(models.Model): blog = models.ForeignKey(Blog)
Given the following models class Blog(models.Model): followers = models.ManyToManyField(User, through='Follow') class Follow(models.Model): blog =
In Django, I have the following models.py class Product(RandomPrimaryIdModel): title = models.CharField(max_length=20, blank=True, null=True)
This is just an example, but given the following model: class Foo(models.model): bar =
Given the following model, I want to index the fields (sequence,stock) class QuoteModel(models.Model): quotedate

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.