class LinkStreamBlockFactory(wagtail_factories.StreamBlockFactory):
internal = factory.SubFactory(PageStructBlockFactory)
document = factory.SubFactory(DocumentStructBlockFactory)
external = factory.SubFactory(ExternalLinkStructBlockFactory)
class Meta:
model = blocks.LinkStreamBlock
class Params:
is_internal = factory.Trait(**{"0": "internal"})
it is not possible to use the is_internal trait, like LinkStreamBlockFactory(is_internal=True), as the is_internal keyword breaks StreamBlockFactory's parameter parsing. This particular use case is somewhat pointless (you could just call LinkStreamBlockFactory(**{"0": "internal"})), but there may be valid use cases for traits (maybe as defining a shorthand for a particular combination of nested options). I would like to hear opinions on this - would fixing this be useful?
Given a factory definition of
it is not possible to use the
is_internal
trait, likeLinkStreamBlockFactory(is_internal=True)
, as theis_internal
keyword breaksStreamBlockFactory
's parameter parsing. This particular use case is somewhat pointless (you could just callLinkStreamBlockFactory(**{"0": "internal"})
), but there may be valid use cases for traits (maybe as defining a shorthand for a particular combination of nested options). I would like to hear opinions on this - would fixing this be useful?