factory_boy icon indicating copy to clipboard operation
factory_boy copied to clipboard

GenericForeignKey recipe without DB access

Open AlexChalk opened this issue 4 years ago • 0 comments

The problem

The docs contain a recipe for using factory_boy with models that have a GenericForeignKey.

This works great for integration tests, but the ContentType.objects.get_for_model(o.content_object)) call requires database access, which in my unit tests is something I'd like to avoid.

Proposed solution

Could you suggest a similar recipe to the one I linked that doesn't involve any kind of db access?

AlexChalk avatar Mar 24 '21 19:03 AlexChalk