- July 25, 2011
- fixtures tests helper
- 1 (after 1 ratings)
This lets you load global fixtures from a directory you set as
FIXTURES_ROOT in your settings.py.
For example, setting
I tend to like to keep fixtures that should be loaded when a new instance of a site is deployed, but not auto-loaded (so they won't rewrite any data that comes after), in a project-level fixtures directory like this.
Sometimes these fixtures can be useful in your test suites, so this is a convenient way to load them.
load_global_fixtures('sites.json', 'contacts.json', fixtures_root='/some/other/path', verbosity=1)
1 2 3 4 5 6 7 8 9 10 11 12 13 14
import os from django.core import management from django.conf import settings def load_global_fixtures(*fixtures, **opts): options = dict(fixtures_root=settings.FIXTURES_ROOT, verbosity=0) options.update(opts) for fixture in fixtures: management.call_command('loaddata', os.path.join(options['fixtures_root'], fixture), verbosity=options['verbosity'])
More like this
- Unit Tests That Write Fixtures by justquick 7 years, 2 months ago
- Load local settings by ofalk 6 years, 10 months ago
- Setting distinction between development and public server by Archatas 9 years, 1 month ago
- 3rd Party App Directories by thalin 7 years, 10 months ago
- Use MEDIA_URL in flatpages by robhudson 8 years, 1 month ago