factory_boy icon indicating copy to clipboard operation
factory_boy copied to clipboard

Auto-generated keys in factory.Dict()?

Open oren0e opened this issue 2 years ago • 0 comments

Hi, I'm looking for a way to make something like this work:

class SomeResponse(factory.BaseDictFactory):
    class Meta:
        model = dict
    
    slots = factory.Dict({
    factory.Sequence(lambda i: f"SLOT{i}"): "foo",
    })

I want to be able to use Sequence() on keys as well. This is all part of me writing a test for something that returns a nested json response. Can it be done?

oren0e avatar Jul 19 '21 13:07 oren0e