Django test fixtures

I want to use some tests in my tests.

I have a cms_sample application and a folder with documents inside: cms_sample_data.xml

I use the following in my test.py :

 class Functionality(TestCase): fixtures = ['cms_sample_data'] 

I am using TestCase django.tests , not unittest .

But the appliances are not loaded. What am I missing?

+6
django unit-testing testing fixtures
source share
4 answers

Forgot xml extension?

 class Functionality(TestCase): fixtures = ['cms_sample_data.xml'] 
+1
source share

your cms_sample_data file may be an error. you can use this command: manage.py loaddata cms_sample_data p>

to check the file.

0
source share

I had a similar problem when I found out about this topic in Django docs. As I decided, this changed the format file, which saved my device in the appropriate format. Initially, I saved the device, which was a regular text file named "test_db.json". As soon as I understood this, I changed the ".txt" file to the ".JSON" file. He began to load the device himself, as soon as I typed the command ./manage.py test.

0
source share

Do you use multiple databases? If so, your test may need to set the multi_db property:

 multi_db = True 
0
source share

All Articles