Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

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')

Release History

This version
History Node


History Node


Download Files

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

File Name & Hash SHA256 Hash Help Version File Type Upload Date
(6.3 kB) Copy SHA256 Hash SHA256
Source Nov 5, 2017

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting