I didn't see anywhere that LiveServerTestCase wasn't loading fixtures, but when i execute the following :
class FrontTest(LiveServerTestCase):
fixtures = ['event.json']
@classmethod
def setUpClass(cls):
super().setUpClass()
print(Event.objects.all())
The output is :
Using existing test database for alias 'default'...
[]
While when i use TestCase
class FrontTest(TestCase):
fixtures = ['event.json']
@classmethod
def setUpClass(cls):
super().setUpClass()
print(Event.objects.all())
The ouput is :
[<Event: event search>]
Do you know why my fixture is loaded only in TestCase ? I'd really like to make it work to use Selenium. Thanks !
PS : event.json :
{
"model": "mezzanine_agenda.event",
"pk": 1,
"fields": {
"comments_count": 0,
"keywords_string": "",
"rating_count": 0,
"rating_sum": 0,
"rating_average": 0.0,
"site": 1,
"title": "event search",
"slug": "event-search",
"_meta_title": "",
"description": "event search",
"gen_description": true,
"created": "2018-05-25T15:49:55.223Z",
"updated": "2018-05-25T15:49:55.257Z",
"status": 2,
"publish_date": "2018-05-25T15:49:32Z",
"expiry_date": null,
}
},
from Django : fixtures object not retrievable
No comments:
Post a Comment