class SampleTestCase(TestCase): fixtures = ['person', 'address']
From django/core/management/commands/loaddata.py Line 95
for fixture_label in fixture_labels: parts = fixture_label.split('.')
fixture_labels default is [initial_data, ] , here we define fixtures = [‘person’, ‘address’], so
fixture_labels is [‘initial_data’, ‘person’, ‘address’]
From django/core/management/commands/loaddata.py Line 98
if len(parts) > 1 and parts[-1] in compression_types: compression_formats = [parts[-1]] parts = parts[:-1] else: compression_formats = compression_types.keys() if len(parts) == 1: fixture_name = parts formats = serializers.get_public_serializer_formats() else: fixture_name, format = '.'.join(parts[:-1]), parts[-1] if format in serializers.get_public_serializer_formats(): formats = [format] else: formats = 
If we list in the SampleTestCase.fixtures didn’t have a compression formats. By default,
compression_formats is [‘gz’, ‘zip’, ‘bz2’].
If parts didn’t have formats such as ‘json’, ‘xml’, formats will be [‘xml’, ‘json’], in the later, program will be to guess the possible format.
Here, we only have filename is person, address, so program will guess the formats.
From django/core/management/commands/loaddata.py Line 126
if os.path.isabs(fixture_name): fixture_dirs = [fixture_name] else: fixture_dirs = app_fixtures + list(settings.FIXTURE_DIRS) + ['']
If file in the
fixtures is a absolute path, program will search only in the path. Otherwise, program will search all the apps_fixtures paths.
From django/core/management/commands/loaddata.py Line 136
for combo in product([using, None], formats, compression_formats): database, format, compression_format = combo file_name = '.'.join( p for p in [ fixture_name, database, format, compression_format ] if p )
combo will be the Cartesian product constructed by filename, formats, compression_formats.
From django/core/management/commands/loaddata.py Line 148
full_path = os.path.join(fixture_dir, file_name) open_method = compression_types[compression_format] try: fixture = open_method(full_path, 'r')
full_path is the possible fixture_dir + file_name, program will tend to open it, if failed, program tries another.
Above all, we can get that we had better to decide a absolute path and absolute filename in the fixtures to avoid meaningless guess.