tests.py
home_page function
'''from django.test import TestCase # Create your tests here. class Smokeclass(TestCase): def test_bad_maths(self): self.assertEquals(1+1,3)'''''
from django.urls import resolve
from django.test import TestCase
from lists.views import home_page
class HomePageTest(TestCase):
def test_root_url_resolve_to_home_page_view(self):
found=resolve('/')#resolve The function is django Functions used internally , For parsing url, And map it to the corresponding view function , When checking the site root path "/", Can I find home_page function
self.assertEquals(found.func,home_page)
urls.py
"""superlists URL Configuration The `urlpatterns` list routes URLs to views. For more information please see: https://docs.djangoproject.com/en/1.10/topics/http/urls/ Examples: Function views 1. Add an import: from my_app import views 2. Add a URL to urlpatterns: url(r'^$', views.home, name='home') Class-based views 1. Add an import: from other_app.views import Home 2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home') Including another URLconf 1. Import the include() function: from django.conf.urls import url, include 2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls')) """
from django.conf.urls import url
from django.contrib import admin
from lists import views
from django.conf.urls import url
urlpatterns = [
# url(r'^admin/', admin.site.urls),
url(r'^$',views.home_page,name='home'),
]
views.py
from django.shortcuts import render
# Create your views here.
def home_page():
pass