clean way to load fixtures in tests

19 views
Skip to first unread message

Matteo Dello Ioio

unread,
Nov 10, 2014, 11:05:24 AM11/10/14
to lettuc...@googlegroups.com
Hi, I'm looking for a clean way to load fixtures data in lettuce's tests.
For unit tests it's pretty easy, just set "fixtures" property inherited from TestCase. 
Isn't there something similar for Lettuce?


Thanks in advance

Michel Sabchuk

unread,
Nov 18, 2014, 8:50:03 AM11/18/14
to lettuc...@googlegroups.com
Hi Matteo,

I use to make a hook to run "call_command":

@before.each_scenario
@before.outline
def reset_data(scenario, *args):
    call_command('flush', interactive=False, verbosity=0)
    call_command('loaddata', 'some_initial.json', verbosity=0)

And, when I need an specific fixture, I just create a step to load it:

Given I have a ferrari in my garage

@step('I have a ferrari in my garage')
def load_a_ferrari(step):
    call_command('loaddata', 'ferrari.json', verbosity=0)

Best regards,
Reply all
Reply to author
Forward
0 new messages