mirror of
https://github.com/django/django.git
synced 2025-08-04 02:48:35 +00:00
Converted test fixtures to setUpTestData methods
This commit is contained in:
parent
d6969abf23
commit
39a7eed1bb
69 changed files with 2077 additions and 2819 deletions
|
@ -1,3 +1,4 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import datetime
|
||||
|
@ -7,12 +8,25 @@ from django.test import TestCase, override_settings
|
|||
from django.utils.encoding import force_str
|
||||
from django.views.generic.base import View
|
||||
|
||||
from .models import Artist, Author, Book
|
||||
from .models import Artist, Author, Book, Page
|
||||
|
||||
|
||||
@override_settings(ROOT_URLCONF='generic_views.urls')
|
||||
class ListViewTests(TestCase):
|
||||
fixtures = ['generic-views-test-data.json']
|
||||
|
||||
@classmethod
|
||||
def setUpTestData(cls):
|
||||
cls.artist1 = Artist.objects.create(name='Rene Magritte')
|
||||
cls.author1 = Author.objects.create(name='Roberto Bolaño', slug='roberto-bolano')
|
||||
cls.author2 = Author.objects.create(name='Scott Rosenberg', slug='scott-rosenberg')
|
||||
cls.book1 = Book.objects.create(name='2066', slug='2066', pages=800, pubdate=datetime.date(2008, 10, 1))
|
||||
cls.book1.authors.add(cls.author1)
|
||||
cls.book2 = Book.objects.create(
|
||||
name='Dreaming in Code', slug='dreaming-in-code', pages=300, pubdate=datetime.date(2006, 5, 1)
|
||||
)
|
||||
cls.page1 = Page.objects.create(
|
||||
content='I was once bitten by a moose.', template='generic_views/page_template.html'
|
||||
)
|
||||
|
||||
def test_items(self):
|
||||
res = self.client.get('/list/dict/')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue