Microsoft Windows [Version 6.0.6002] Copyright (c) 2006 Microsoft Corporation. All rights reserved.
C:\Users\mech10>cd superlists
C:\Users\mech10\superlists>python manage.py test
Creating test database for alias 'default'...
E
ERROR: lists.tests (unittest.loader._FailedTest)
ImportError: Failed to import test module: lists.tests
Traceback (most recent call last):
File "C:\Users\mech10\Anaconda3\lib\unittest\loader.py", line 428,in _find_test_path
module = self._get_module_from_name(name)
File "C:\Users\mech10\Anaconda3\lib\unittest\loader.py", line 369, in _get_module_from_name__import__(name)
File "C:\Users\mech10\superlists\lists\tests.py", line 9
self.assertEqual(found.func,home_page)
^
TabError: inconsistent use of tabs and spaces in indentation
Ran 1 test in 0.001s
FAILED (errors=1)
Destroying test database for alias 'default'...
tests.py
from django.core.urlresolvers import resolve
from django.test import TestCase
from lists.views import home_page
class HomePageTest(TestCase):
def test_root_url_resolves_to_home_page_view(self):
found = resolve('/')
self.assertEqual(found.func,home_page)
urls.py
from django.conf.urls import url
from django.contrib import admin
urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'^$', 'lists.views.home_page', name='home'),
]
views.py
from django.shortcuts import render
def home_page():
pass
I want to follow the instructions from a django test book but I could not understand my test script did not work.
Aucun commentaire:
Enregistrer un commentaire