Skip to main content
Join the official 2020 Python Developers SurveyStart the survey!

Build fixtures from a single source

Project description


$ pip install fixturebuilder


# define the data structure to be worked on
start_data = {
    'prop1': 'value1',
    'prop2': 'value2',
    'dict1': {
        'dictprop1': 'dictvalue1'
    'list1': [
    'list2': [
        {'listdictprop1': 'listdictprop1', 'listdictlist1': ['listdictlistvalue1']}

# initialize a new builder
builder = FixtureBulder.create(start_data)

# retrieve the data unchanged
test_data1 =

# set a new value on a property and retrieve the updated data
test_data2 = builder.set('prop1', 1).data

# do complex manipulation on the start_data and retrieve the modified data
test_data3 = builder
    .with_dict('dict1')  # descend into 'dict1' and work on it's properties
        .set('dictprop1', 12)
        .set('newlist', ['value'])
        .add('newlist', 'additional value')  # add a new value to a list
        .set('newdict', {'someprop': 'some value'})
            .set('someprop', 'change previously created value')
        .done()  # finish working on 'newdict' and return to 'dict1'
    .done()  # finish working on 'dict1' and return to the root

test_data4 = builder
    .duplicate_last_list_entry('list2')  # append a duplicated dict to the list
    .with_dict_list_element('list2')     # descend into the last list element to work on it's properties
        .add('listdictlist1', 'new value1')
        .set('listdictprop1', False)
    .done()  # finish working on the list element and return to the root

# retrieve the original unmodified data
original_data =

# setting new property raises an error
builder.set('newprop', 'newvalue')

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for fixturebuilder_py, version 1.2.9
Filename, size File type Python version Upload date Hashes
Filename, size fixturebuilder_py-1.2.9.tar.gz (6.3 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page