croach / Flask-Fixtures

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

Doing per-test fixtures? #15

Closed jkugler closed 9 years ago

jkugler commented 9 years ago

I came across this project today, and it appears to be exactly what I want. There is one feature that would make life a little easier for me. If this feature is there, please forgive intrusion (I haven't looked at the code).

Is there a way to specify the yaml/json file(s) per test? I have several tests involving the User class, for example, but don't want the same set of records for each test. I'd rather not have a proliferation of TestClasses just because I need different fixtures.

Thanks!

And if I missed anything about a mailing list, I apologize.

croach commented 9 years ago

Hi @jkugler,

Right now the library doesn't support different fixtures files for each test. That is about to change though. I have two Issues that I created that deal with running fixtures on a per test basis (Issue #2 and Issue #6). You can read through them if you're interested, but the short version is that the first version of Flask-Fixtures used decorator functions instead of metaclasses to specify the class and/or method that you wanted to run fixtures on. This had problems with how the library interacted with custom setUp and tearDown methods, so I had to change the overall design of the library to use a combination of metaclasses and decorators instead. I've finished the first part of fixing these bugs, i.e., the switch to metaclasses, but I haven't yet finished the second part, i.e., making it possible to select a fixtures file for each individual test function. I'm working on the second part now though, and it should be finished very soon, so keep your eyes peeled and thanks for using the library!

Christopher

jkugler commented 9 years ago

Sounds great! I look forward to seeing the enhancements.