I know fixtures can be loaded in the tests.py like this:
fixtures = ['example.json']
Django automatically search all the apps' fixture directory and load the fixtures.
However, I create a reusable app named accounts
and in accounts
I also have the fixtures/example.json
file. But when I installed the accounts
app and write it into the INSTALLED_APP
settings, the fixture cannot be loaded. I am curious why it happens.
Django == 1.8.2
You might be able to load those fixtures if:
package_data={'mypkg': ['fixtures/*.json']}
depending on your configurationSettings.py:
ENV_DIR = os.path.join(os.path.dirname(__file__), '..')
FIXTURE_DIRS = (
os.path.join(VENV_DIR, "virtualenv/lib/python2.7/site-packages/yourapp/test/fixtures"),
)
Note that it will depends on local system, not a clean solution, but it works, pay attention if you are running tests on remote systems like jenkins because you'll have to change this configuration according to the server deployment settings.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With