I wrote some tests for my Django models that depend on an initial dataset on the database. I'm used to have a initial_data.json fixture and optional fixtures that are loaded per test. These fixtures are loaded automatically during the manage.py test someapp command and all my tests pass. As I decided to do testing directly in PyCharm, I created a Django Test run configuration and set someapp as its target. I was surprised to discover that all tests failed.
The Traceback is normally something like:
Traceback (most recent call last):
File "/usr/lib/python2.7/unittest/case.py", line 318, in run
File "/home/rafael/Repos/sales_fencing/sf/apps/sales_fencing/tests.py", line 29, in setUp
user = User.objects.get(username='wilerson')
File "/home/rafael/sf_env/local/lib/python2.7/site-packages/django/db/models/manager.py", line 132, in get
return self.get_query_set().get(*args, **kwargs)
File "/home/rafael/sf_env/local/lib/python2.7/site-packages/django/db/models/query.py", line 349, in get
DoesNotExist: User matching query does not exist.
Which indicates that the fixtures were not loaded by the Pycharm testing script. I confirmed this by observating the test_someapp database during the tests.
Is this a bug or should I configure Pycharm properly to load this fixtures during tests?