Django

Code

Ticket #4371: fixtures_test.diff

File fixtures_test.diff, 1.3 kB (added by keithb, 1 year ago)

Patch for tests.modeltests.fixtures

  • models.py

    old new  
    7575# Dump the current contents of the database as a JSON fixture 
    7676>>> management.call_command('dumpdata', 'fixtures', format='json') 
    7777[{"pk": "3", "model": "fixtures.article", "fields": {"headline": "Time to reform copyright", "pub_date": "2006-06-16 13:00:00"}}, {"pk": "2", "model": "fixtures.article", "fields": {"headline": "Poker has no place on ESPN", "pub_date": "2006-06-16 12:00:00"}}, {"pk": "1", "model": "fixtures.article", "fields": {"headline": "Python program becomes self aware", "pub_date": "2006-06-16 11:00:00"}}] 
     78 
     79# redirect stderr for the next few tests... 
     80>>> import sys 
     81>>> savestderr = sys.stderr 
     82>>> sys.stderr = sys.stdout 
     83 
     84# Loading data of an unknown format should fail 
     85>>> management.call_command('loaddata', 'bad_fixture1.unkn', verbosity=0) 
     86Problem installing fixture 'bad_fixture1': unkn is not a known serialization format. 
     87 
     88# Loading a fixture file with invalid data 
     89>>> management.call_command('loaddata', 'bad_fixture2.xml', verbosity=0) 
     90Empty fixture file 'bad_fixture2' found. (File format may be invalid.) 
     91 
     92>>> sys.stderr = savestderr 
    7893"""} 
    7994 
    8095from django.test import TestCase