0

I wanted to know if in the tests it is possible to somehow create an "artificial" model using FactoryBoy without touching models.py

I mean a simple model such as:

class SomeMod(models.Model):
    title = models.CharField(max_length=255, blank=True, null=True)
    description = models.CharField(max_length=255, blank=True, null=True)

    def __str__(self):
        return self.title
Hide856
  • 35
  • 6

1 Answers1

0

You may be looking for the attribute abstract in the Meta options of the factory class, which is mentioned here in Factory Boy documentation.

from factory.django import DjangoModelFactory
from factory import Faker

class MyAbstractFactory(DjangoModelFactory):
    title = Faker("last_name") # could be "company" or whatever you want to mock
    description = Faker("paragraph")

    class Meta:
         abstract = True

Is this what you're looking for? If not, please elaborate your question.

scūriolus
  • 657
  • 2
  • 5
  • 15