6

I want to use some fixtures in my tests.

I have cms_sample app and a fixtures folder inside with: cms_sample_data.xml

I use the following in my test.py:

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

I do use TestCase of django.tests and not unittest.

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

8
  • 1
    Try running with python manage.py test api --verbosity 2 It might give a clue where it is looking. Commented Feb 3, 2010 at 11:42
  • OK. I see that he checks for initial_data fixtures, but he is not looking for the cms_sample_data fixture. Any ideas? Commented Feb 3, 2010 at 13:01
  • Does this fixture work when loaded manually? Commented Feb 3, 2010 at 13:18
  • where is it located on filepath? Commented Feb 3, 2010 at 22:55
  • 1
    I have exactly the same problem too - did you ever find a solution? Commented Dec 28, 2010 at 21:58

4 Answers 4

1

Forgot the xml-extension?

class Functionality(TestCase): fixtures = ['cms_sample_data.xml']
Sign up to request clarification or add additional context in comments.

3 Comments

Since you checked this as the answer, can you please explain?
He thought it not be like it was, but it do.
-1 for failing to justify adding the extension. Django will look for fixtures of any extension when you don't provide one; adding the extension only makes it easier for Django to locate that specific extension by narrowing the search to files with that exact name.
0

perhaps your cms_sample_data file is error. you can use this comand: manage.py loaddata cms_sample_data

to check the file.

Comments

0

I had a similar problem while learning about this subject on Django's docs. How I solved it was changing the format file that stored my fixture to the proper format. Originally, I saved the fixture was an ordinary text file with the name "test_db.json". Once I realized this, I changed the ".txt" file into a ".JSON" file. It began to load the fixture on its own once I typed in the "./manage.py test" command.

Comments

0

Are you using multiple databases? If so, your test might need to set the multi_db property:

multi_db = True

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.