Overview

Overview

fixture-yaml is an extension that adds YAML support to fixture library allowing to use Ruby style YAML fixtures.

Usage

Here's a small usage example in conjunction with SQLAlchemy model:

from pkg_resources import resource_filename
from unittest import TestCase

from fixture import SQLAlchemyFixture
from fixture_yaml import YAMLSet
from sqlalchemy import create_engine
from sqlalchemy.engine.url import make_url

from app import models
from app.meta import metadata, Session

class ModelsTest(TestCase):
    def setUp(self):
        engine = create_engine(make_url('sqlite:///:memory:'))
        Session.configure(bind=engine)
        metadata.bind = engine
        metadata.create_all()
        self.fixture = SQLAlchemyFixture(env=models, engine=engine)
        self.data = self.fixture.data(
            YAMLSet(resource_filename(__name__, 'user.yml')),
            YAMLSet(resource_filename(__name__, 'group.yml')),
        )
        self.data.setup()

    def tearDown(self):
        Session.remove()
        self.data.teardown()
        metadata.drop_all()