Django

Code

Show
Ignore:
Timestamp:
06/08/08 03:21:18 (7 months ago)
Author:
russellm
Message:

Fixed #4371 -- Improved error checking when loading fixtures. Code now catches explicitly named fixture formats that are not supported (e.g, YAML fixtures if you don't have PyYAML installed), and fixtures that are empty (which can happen due to XML tag errors). Thanks to John Shaffer for the suggestion, and Keith Bussell for his work on the fix.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/tests/regressiontests/fixtures_regress/models.py

    r7145 r7595  
    72721 
    7373 
     74############################################### 
     75# Test for ticket #4371 -- fixture loading fails silently in testcases 
     76# Validate that error conditions are caught correctly 
     77 
     78# redirect stderr for the next few tests... 
     79>>> import sys 
     80>>> savestderr = sys.stderr 
     81>>> sys.stderr = sys.stdout 
     82 
     83# Loading data of an unknown format should fail 
     84>>> management.call_command('loaddata', 'bad_fixture1.unkn', verbosity=0) 
     85Problem installing fixture 'bad_fixture1': unkn is not a known serialization format. 
     86 
     87# Loading a fixture file with invalid data using explicit filename 
     88>>> management.call_command('loaddata', 'bad_fixture2.xml', verbosity=0) 
     89No fixture data found for 'bad_fixture2'. (File format may be invalid.) 
     90 
     91# Loading a fixture file with invalid data without file extension 
     92>>> management.call_command('loaddata', 'bad_fixture2', verbosity=0) 
     93No fixture data found for 'bad_fixture2'. (File format may be invalid.) 
     94 
     95>>> sys.stderr = savestderr 
     96 
    7497"""}