summaryrefslogtreecommitdiff
path: root/tutorial_10_django_tests
diff options
context:
space:
mode:
authorprathamesh2018-04-17 12:08:28 +0530
committerprathamesh2018-04-17 12:08:28 +0530
commit654580bb4735829fe792e521c16e86ad70b4900d (patch)
tree1752c433e7c0c84f809f582de6354ead120add72 /tutorial_10_django_tests
parente06c6e81ef80cff3cf1f5a64506ac7d3e317c7fb (diff)
downloadlearn_django-654580bb4735829fe792e521c16e86ad70b4900d.tar.gz
learn_django-654580bb4735829fe792e521c16e86ad70b4900d.tar.bz2
learn_django-654580bb4735829fe792e521c16e86ad70b4900d.zip
Add Outputs for reference
Diffstat (limited to 'tutorial_10_django_tests')
-rw-r--r--tutorial_10_django_tests/slides.md51
1 files changed, 47 insertions, 4 deletions
diff --git a/tutorial_10_django_tests/slides.md b/tutorial_10_django_tests/slides.md
index 0365e34..da97a0e 100644
--- a/tutorial_10_django_tests/slides.md
+++ b/tutorial_10_django_tests/slides.md
@@ -36,7 +36,7 @@ Slide 5
** Testing in Django**
- Automated testing is very useful
- We can validate our code during development
- - Testing is very complex,as we need to test models, views and forms.
+ - Testing is very complex, as we need to test models, views and forms.
- In this tutorial we learn to write tests for models
Demonstration
@@ -63,7 +63,17 @@ Demonstration
python manage.py test blog
-We will see test Ran successfully
+We will see test ran successfully as follow:
+
+ Creating test database for alias 'default'...
+ System check identified no issues (0 silenced).
+ .
+ ----------------------------------------------------------------------
+ Ran 1 test in 0.002s
+
+ OK
+ Destroying test database for alias 'default'...
+
Demonstration
-------------
@@ -74,6 +84,10 @@ Demonstration
is_created_recently = True
self.assertEqual(blog.was_created_recently(), is_created_recently)
- Run
+ - Output will be same as above except for following:
+
+ Ran 2 tests in 0.003s
+
Demonstration
-------------
@@ -88,7 +102,24 @@ Demonstration
- Run
- - Show assertion error in the output
+ - Show assertion error in the following output:
+
+ Creating test database for alias 'default'...
+ System check identified no issues (0 silenced).
+ .F
+ ======================================================================
+ FAIL: test_was_created_recently (blog.tests.BlogTestCase)
+ ----------------------------------------------------------------------
+ Traceback (most recent call last):
+ File "/home/ttt/my-django/myproject/mysite/blog/tests.py", line 19, in test_was_created_recently
+ self.assertEqual(blog.was_created_recently(), is_created_recently)
+ AssertionError: True != False
+
+ ----------------------------------------------------------------------
+ Ran 2 tests in 0.003s
+
+ FAILED (failures=1)
+ Destroying test database for alias 'default'...
Demonstration
@@ -102,13 +133,25 @@ Demonstration
self.assertTrue(blog.was_created_recently())
- Run
+ - Output
+
+ Ran 2 tests in 0.003s
+
+ OK
Demonstration
--------------
- Run individual test case
- python manage.py shell test blogs.tests.test_was_created_recently
+ - python manage.py test blog.tests.BlogTestCase.test_was_created_recently
+
+ - Output
+
+ Ran 1 test in 0.002s
+
+ OK
+
Demonstration
--------------