pytest-factoryboy icon indicating copy to clipboard operation
pytest-factoryboy copied to clipboard

[Feature request] Traits as fixtures?

Open David-Guillot opened this issue 8 years ago • 2 comments

Hi,

I'd like to parametrize use of a Factoryboy Trait. But i don't see my Traits when i list my fixtures, so i get there is something missing here.

I honestly don't know if that would even be possible, so if it's not, please explain why ;) Thanks

David-Guillot avatar Sep 06 '17 11:09 David-Guillot

I didn't use them yet for my projects :) Need to do some investigation

olegpidsadnyi avatar Feb 02 '18 14:02 olegpidsadnyi

Here's what I expected it to be:

class UserFactory(DjangoModelFactory):    
    class Params:
        my_trait = factory.Trait(
            has_done_thing=True,
            something_else=1,
            # ...
        )
        
@pytest.mark.parametrize("user__my_trait", [True])
@pytest.mark.parametrize("user__something_else", [2])

Traits are primarily a shortcut for supplying lots of parameters by wrapping them up under one bool, and they can still be overridden, so I expected pytest-factoryboy to follow the same pattern.

stevelacey avatar Sep 24 '21 09:09 stevelacey