From 4bd5c61c396c0406f547b8576207c6a25fbd4c8a Mon Sep 17 00:00:00 2001 From: ikkiran Date: Mon, 30 Jan 2012 12:57:09 +0530 Subject: Few changes: R4 - R7. --- TDD/using_python_framework_for_tdd/tdd2_script.rst | 26 +++++++++++----------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'TDD/using_python_framework_for_tdd') diff --git a/TDD/using_python_framework_for_tdd/tdd2_script.rst b/TDD/using_python_framework_for_tdd/tdd2_script.rst index ca503f1..e460f70 100755 --- a/TDD/using_python_framework_for_tdd/tdd2_script.rst +++ b/TDD/using_python_framework_for_tdd/tdd2_script.rst @@ -49,15 +49,15 @@ tutorial on "Test driven development-part 1". .. R4 -To test ``fibonacci`` function we have used two test cases. +To test ``fibonacci`` function, we have used two test cases. It is inconvenient to repeatedly change the test conditions in -the fibonacci.py file.Each time a new test case is added it -introduces a 'if' statement too. -So it is good practice to write the test cases in a separate file. -The file will contain multiple lines,each line for separate test case, -each line consist of two comma separated values, -first column is the integer value which has to be passed to the function - and the second column is the return value from the function. +the fibonacci.py file. Each time a new test case is added, it +introduces an 'if' statement too. +So, it is a good practice to write the test cases in a separate file. +This file containa multiple lines, each line representing a test case. +Each line consists of two comma separated values in which the +first column is the integer value that has to be passed to the function. + The second column is the return value from the function. @@ -69,8 +69,8 @@ first column is the integer value which has to be passed to the function .. R5 -Lets open the same fibonacci.py file which we have used in our -previous tutorial.Change the code to use fibonacci_testcases.dat +Let us open the fibonacci.py file which we have used in our +previous tutorial. Now, change the code to use 'fibonacci_testcases.dat' file for test cases. @@ -81,7 +81,7 @@ file for test cases. .. R6 -Save the fibonacci.py file. Go to terminal and run +Save the fibonacci.py file. Switch to terminal and run ``python fibonacci.py``. It should pass all the tests. @@ -95,9 +95,9 @@ Save the fibonacci.py file. Go to terminal and run .. R7 So far we have used simple repetitive tests. -Now we will see how ``Python testing frameworks`` can do the +Now, let us see how ``Python testing frameworks`` does the same job efficiently. -Python provides two frameworks for testing code, unittest and +Python provides two frameworks for testing code: unittest and doctest. .. L7 -- cgit From 70562e864d4122d30653e781d3a472a65f8f7dac Mon Sep 17 00:00:00 2001 From: ikkiran Date: Mon, 30 Jan 2012 13:09:16 +0530 Subject: Changes: R8 - End. --- TDD/using_python_framework_for_tdd/tdd2_script.rst | 30 +++++++++++----------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'TDD/using_python_framework_for_tdd') diff --git a/TDD/using_python_framework_for_tdd/tdd2_script.rst b/TDD/using_python_framework_for_tdd/tdd2_script.rst index e460f70..be41e6d 100755 --- a/TDD/using_python_framework_for_tdd/tdd2_script.rst +++ b/TDD/using_python_framework_for_tdd/tdd2_script.rst @@ -54,7 +54,7 @@ It is inconvenient to repeatedly change the test conditions in the fibonacci.py file. Each time a new test case is added, it introduces an 'if' statement too. So, it is a good practice to write the test cases in a separate file. -This file containa multiple lines, each line representing a test case. +This file contains multiple lines, each line representing a test case. Each line consists of two comma separated values in which the first column is the integer value that has to be passed to the function. The second column is the return value from the function. @@ -106,25 +106,25 @@ doctest. .. R8 -Let us first see how doctest works. +First, let us see how doctest works. A docstring is used to document function. Along with the description, interactive interpretor session's input and output are also added. -When executed doctest module pick up all such interactive +When executed, the doctest module picks up all such interactive examples, executes them and determines if the code runs as documented. .. L8 -{{{switch to slide7 for 3 seconds and move to to slide8, +{{{switch to slide7 for 3 seconds and move to slide8, Doctest for fibonacci.py}}} .. R9 -To initiate doctest we need to import doctest module. +To initiate doctest, we need to import the doctest module. Testmod automatically picks all sample sessions, executes them and compares with the documented output. -Doctest doesn't give any output when all test pass, +Doctest doesn't give any output when all the tests pass, it complains only when any test fails. .. L9 @@ -135,7 +135,7 @@ it complains only when any test fails. Let us run doctests by typing ``python fibonacci.py``. As all tests pass, doctest doesn't give any output. -For more detailed information we can run with -v argument. +For detailed information, we may run the file with -v argument. Run as ``python -v fibonacci.py``. .. L10 @@ -150,19 +150,19 @@ Run as ``python -v fibonacci.py``. So far we have seen doctest, which is simple to use. But when it comes to automate the process, unittest is better. -Unittest initializes code and data, it aggregate +Unittest initializes code and data, it aggregates tests into collections and improves reporting. .. L11 -{{{ switch to slide-11, Unittest }}} +{{{ Switch to slide-11, Unittest }}} .. R12 -To run unittest on our fibonacci function let us create a -new file ``test_fibonacci.py``. This new file will host the -test code. To begin unittesting let us subclass +To run unittest on our fibonacci function, let us create a +new file ``test_fibonacci.py``. This new file hosts the +test code. To begin unittesting, let us subclass the TestCase class in unittest. We need fibonacci.py and fibonacci_testcases.py files too. @@ -173,10 +173,10 @@ test code. To begin unittesting let us subclass .. R13 -This brings us to the end of the tutorial.In this tutorial, +This brings us to the end of the tutorial. In this tutorial, we have learnt to, - 1. Undestand the basic steps involved in Test driven development. + 1. Understand the basic steps involved in Test driven development. #. Design a Test driven approach for a given ``fibonacci`` function. @@ -213,5 +213,5 @@ Thank you! .. L16 -{{{ Switch to slide-16, Thankyou}}} +{{{ Switch to slide-16, Thank you}}} -- cgit From 9c943d7375af3ed25c2c1d32f42bdf359f13d115 Mon Sep 17 00:00:00 2001 From: ikkiran Date: Mon, 30 Jan 2012 13:54:14 +0530 Subject: Minor Changes: R10. --- TDD/using_python_framework_for_tdd/tdd2_script.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'TDD/using_python_framework_for_tdd') diff --git a/TDD/using_python_framework_for_tdd/tdd2_script.rst b/TDD/using_python_framework_for_tdd/tdd2_script.rst index be41e6d..53165fa 100755 --- a/TDD/using_python_framework_for_tdd/tdd2_script.rst +++ b/TDD/using_python_framework_for_tdd/tdd2_script.rst @@ -44,7 +44,7 @@ At the end of this tutorial, you will be able to, .. R3 -Before beginning this tutorial,we would suggest you to complete the +Before beginning this tutorial,we suggest you to complete the tutorial on "Test driven development-part 1". .. R4 @@ -133,7 +133,7 @@ it complains only when any test fails. .. R10 -Let us run doctests by typing ``python fibonacci.py``. +Let us run doctest by typing ``python fibonacci.py``. As all tests pass, doctest doesn't give any output. For detailed information, we may run the file with -v argument. Run as ``python -v fibonacci.py``. -- cgit