第一个单元测试通过。
$ python manage.py test
Creating test database for alias ‘default’…
.———————————————————————-
Ran 1 test in 0.002s
OK
Destroying test database for alias ‘default’…
$ git diff
diff –git a/.gitignore b/.gitignore
index 49ef255..3ba11e5 100644
— a/.gitignore
+++ b/.gitignore
@@ -1 +1,3 @@
db.sqlite3
+pycache
+*.pyc
diff –git a/geckodriver.log b/geckodriver.log
index 4acb960..ba571e6 100644
— a/geckodriver.log
+++ b/geckodriver.log
@@ -53,3 +53,12 @@ JavaScript error: http://bdimg.share.baidu.com/static/api/js/trans/logger.js?v=d
1481553714807 Marionette INFO Listening on port 37657
^G[Child 7364] ###!!! ABORT: Aborting on channel error.: file /build/firefox-RaD34G/firefox-50.0+build2/ipc/glue/MessageChannel.cpp, line 2056
[Child 7364] ###!!! ABORT: Aborting on channel error.: file /build/firefox-RaD34G/firefox-50.0+build2/ipc/glue/MessageChannel.cpp, line 2056
+
+(firefox:5917): Gdk-WARNING **: firefox: Fatal IO error 11 (资源暂时不可用) on X server :0.
+(/usr/lib/firefox/plugin-container:5982): Gdk-WARNING **: /usr/lib/firefox/plugin-container: Fatal IO error 11 (资源暂时不可用) on X server :0.
+
+/usr/lib/firefox/plugin-container: Fatal IO error 11 (资源暂时不可用) on X server :0.
+^G[NPAPI 6983] ###!!! ABORT: Aborting on channel error.: file /build/firefox-RaD34G/firefox-50.0+build2/ipc/glue/MessageChannel.cpp, line 2056
+[NPAPI 6983] ###!!! ABORT: Aborting on channel error.: file /build/firefox-RaD34G/firefox-50.0+build2/ipc/glue/MessageChannel.cpp, line 2056
diff –git a/lists/tests.py b/lists/tests.py
index e3ac0ca..daacc8a 100644
— a/lists/tests.py
+++ b/lists/tests.py
@@ -1,8 +1,17 @@
-from django.test import TestCase
+#from django.test import TestCase
# Create your tests here
-class SmokeTest(TestCase):
- def test_bad_maths(self):
- self.assertEqual(1+1,3)
+#class SmokeTest(TestCase):
+# def test_bad_maths(self):
+# self.assertEqual(1+1,3)
+
+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_views(self):
+ found = resolve(‘/’)
+ self.assertEqual(found.func,home_page)
$diff –git a/lists/views.py b/lists/views.py
$git commit –am “First unit test and url mapping,dummy view”
test and url mapping,dummy view”
[master 91ea60f] First unit test and url mapping,dummy view
5 files changed, 31 insertions(+), 5 deletions(-)