当我尝试运行此测试时:
from django.test import TestCase
from django.core.urlresolvers import reverse
from django.test import Client
class StatisticTest(TestCase):
def setUp(self):
self.client = Client()
def test_schedule_view(self):
url = reverse('schedule')
response = self.client.get(url)
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, 'schedule.html')
我得到AssertionError:没有用于呈现响应的模板。
这是我的观点:
class Schedule(View):
def get(self, request):
games = add_team_info(query.get_current_schedule())
if games is not []:
available_schedules = generate_schedule_list(games[0]["season_type"], games[0]["week"])
is_available = True
else:
available_schedules = []
is_available = False
return render_to_response("schedule.html",
{"games": games, "available_schedules": available_schedules, "is_available": is_available})
和urls.py:
url(r'^schedule/$', views.Schedule.as_view(), name='schedule'),