croach / Flask-Fixtures

A simple library for adding database fixtures for unit tests using nothing but JSON or YAML.
MIT License
62 stars 30 forks source link

Add a simple variable replacement templating syntax for fixtures #8

Open croach opened 9 years ago

croach commented 9 years ago

In several situations, the developer has added constants to their code that the test test writer would like to reference in the tests. Doing so allows tests to remain unchanged when changes to the value of said constants happen in the codebase. This feature would add a pre-processing step to the ingestion of fixture files that would allow test writers to reference variables within python modules.

For example,

- table: employees
  records:
    - id: 1
      name: Winston Smith
      email: #{ oceania.models.WINSTON_SMITH_EMAIL }
{
    "table": "employees",
    "records": [{
        "id": 1,
        "name": "Winston Smith",
        "email": "#{ oceania.models.WINSTON_SMITH_EMAIL }"
    }]
}
guyskk commented 8 years ago

Another lib named fixture http://farmdev.com/projects/fixture/using-dataset.html support this feature.