<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="https://script.spoken-tutorial.org/skins/common/feed.css?303"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>https://script.spoken-tutorial.org/index.php?action=history&amp;feed=atom&amp;title=Python-3.4.3%2FC4%2FTesting-and-Debugging%2FEnglish-timed</id>
		<title>Python-3.4.3/C4/Testing-and-Debugging/English-timed - Revision history</title>
		<link rel="self" type="application/atom+xml" href="https://script.spoken-tutorial.org/index.php?action=history&amp;feed=atom&amp;title=Python-3.4.3%2FC4%2FTesting-and-Debugging%2FEnglish-timed"/>
		<link rel="alternate" type="text/html" href="https://script.spoken-tutorial.org/index.php?title=Python-3.4.3/C4/Testing-and-Debugging/English-timed&amp;action=history"/>
		<updated>2026-04-16T23:21:11Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.23.17</generator>

	<entry>
		<id>https://script.spoken-tutorial.org/index.php?title=Python-3.4.3/C4/Testing-and-Debugging/English-timed&amp;diff=47718&amp;oldid=prev</id>
		<title>PoojaMoolya: Created page with &quot;{| border=1 |'''Time''' |'''Narration'''  |- |00:01 |Welcome to the spoken tutorial on '''Testing and debugging.'''  |- |00:06 |In this tutorial, you will,  Understand what is...&quot;</title>
		<link rel="alternate" type="text/html" href="https://script.spoken-tutorial.org/index.php?title=Python-3.4.3/C4/Testing-and-Debugging/English-timed&amp;diff=47718&amp;oldid=prev"/>
				<updated>2019-06-10T11:53:30Z</updated>
		
		<summary type="html">&lt;p&gt;Created page with &amp;quot;{| border=1 |&amp;#039;&amp;#039;&amp;#039;Time&amp;#039;&amp;#039;&amp;#039; |&amp;#039;&amp;#039;&amp;#039;Narration&amp;#039;&amp;#039;&amp;#039;  |- |00:01 |Welcome to the spoken tutorial on &amp;#039;&amp;#039;&amp;#039;Testing and debugging.&amp;#039;&amp;#039;&amp;#039;  |- |00:06 |In this tutorial, you will,  Understand what is...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{| border=1&lt;br /&gt;
|'''Time'''&lt;br /&gt;
|'''Narration'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|00:01&lt;br /&gt;
|Welcome to the spoken tutorial on '''Testing and debugging.'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|00:06&lt;br /&gt;
|In this tutorial, you will,  Understand what is '''software testing '''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|00:11&lt;br /&gt;
|Test simple '''functions''' for their '''functionality '''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|00:15&lt;br /&gt;
|'''Automate tests '''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|00:17&lt;br /&gt;
|Understand the need for '''coding style''' and Learn some of the '''standards''' followed by the '''Python Community'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|00:25&lt;br /&gt;
|To record this tutorial, I am using&lt;br /&gt;
&lt;br /&gt;
'''Ubuntu Linux 16.04''' operating system &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|00:32&lt;br /&gt;
|'''Python 3.4.3 '''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|00:35&lt;br /&gt;
|'''IPython 5.1.0''' and '''Gedit text editor'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|00:42&lt;br /&gt;
|To practise this tutorial, you should know how to use '''functions.''' &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|00:48&lt;br /&gt;
|If not, see the relevant '''Python''' tutorials on this website.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|00:53&lt;br /&gt;
|First we will learn about software testing.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|00:57&lt;br /&gt;
| '''Software testing''' is the process to evaluate the functionality of a software or a '''program.'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|01:04&lt;br /&gt;
|It helps to find whether the program met the specified requirements or not.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|01:10&lt;br /&gt;
|It ensures a defect free program so that we will get a quality program.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|01:16&lt;br /&gt;
|All the codes used in this tutorial are available in the '''Code Files''' link of this tutorial. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|01:23&lt;br /&gt;
|You should download in the current working directory and use them.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|01:28&lt;br /&gt;
|Open any text editor and type the following code. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|01:33&lt;br /&gt;
|This is a simple '''function''' to calculate '''gcd''' of two numbers.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|01:38&lt;br /&gt;
|We need a set of '''inputs''' for the variable a and b.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|01:43&lt;br /&gt;
|Save the file as '''find''' underscore '''gcd.py''' in the current '''working directory.'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|01:50&lt;br /&gt;
|Next we will open the file '''test''' underscore '''gcd.py.'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|01:56&lt;br /&gt;
|Let our test case be 48 and 64 as '''a''' and '''b. '''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|02:02&lt;br /&gt;
|For this test case we know that the GCD is 16. So that is the expected '''output.'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|02:11&lt;br /&gt;
|Let us now run the '''script''' and '''test''' our '''code. '''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|02:15&lt;br /&gt;
|Open the '''terminal''' and type '''python3 test''' underscore '''gcd.py'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|02:24&lt;br /&gt;
|We get the '''output''' as '''Test Passed''' which means our '''code''' is correct.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|02:30&lt;br /&gt;
|But there can be a number of cases where the '''gcd function''' might break.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|02:36&lt;br /&gt;
|So, to check where our code is breaking we should run many tests.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|02:42&lt;br /&gt;
| This is where the concept of automating tests comes in.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|02:46&lt;br /&gt;
|Let us first try and automate tests on the '''gcd function. '''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|02:51&lt;br /&gt;
|Open the file '''textcases.txt''' where the various testing parameters are given.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|02:58&lt;br /&gt;
|The structure of the file will have two '''input parameters. '''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|03:03&lt;br /&gt;
|The third '''parameter''' is the correct '''output result'''. We have separated the elements by a space.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|03:11&lt;br /&gt;
|Next let us open the file '''automate''' underscore '''test''' underscore '''gcd.py'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|03:18&lt;br /&gt;
|First we need '''import gcd function''' from '''find''' underscore '''gcd''' in order to use it for testing.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|03:26&lt;br /&gt;
|Next the '''testcases.txt''' file is read line by line.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|03:32&lt;br /&gt;
|The first two '''input parameters''' are assigned to the variables '''x''' and '''y.'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|03:38&lt;br /&gt;
|The third '''parameter''' which is the correct '''output''' value is assigned to the variable '''result.'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|03:44&lt;br /&gt;
|We check whether the value returned by the '''gcd function''' is equal to the value in the '''variable result.'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|03:52&lt;br /&gt;
|Finally it prints the message accordingly.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|03:56&lt;br /&gt;
|In the '''terminal''', type '''python3 automate''' underscore '''test''' underscore '''gcd.py'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|04:05&lt;br /&gt;
|As you can see, all the three '''test cases''' in '''testcases.txt''' are passed. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|04:12&lt;br /&gt;
|The value calculated by the '''gcd function''' is equal to the output value provided in the '''testcases.txt.'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|04:20&lt;br /&gt;
|Pause the video. Try this exercise and then resume the video.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|04:26&lt;br /&gt;
|For the same inputs as '''gcd''' write '''automated tests''' for '''LCM. '''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|04:33&lt;br /&gt;
|Use the data from the file '''lcmtestcases.txt'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|04:38&lt;br /&gt;
|Switch to the '''terminal''' for the solution.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|04:42&lt;br /&gt;
|Let us see the code to calculate '''lcd''' of two numbers. &lt;br /&gt;
&lt;br /&gt;
The file name is '''find''' underscore '''lcm.py'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|04:52&lt;br /&gt;
|This is the data file for the '''lcm''' test cases.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|04:57&lt;br /&gt;
|This file name is '''lcmtestcases.txt'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|05:02&lt;br /&gt;
|Note that both these files should be in the current '''working directory.'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|05:07&lt;br /&gt;
|Let us now run the '''script''' and '''test''' our '''code.'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|05:11&lt;br /&gt;
|Type '''python3 find''' underscore '''lcm.py'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|05:17&lt;br /&gt;
|Here, the third test case failed. Because the corresponding input in '''lcmtestcases.txt''' is incorrect.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|05:26&lt;br /&gt;
|This is to check the behavior of the program on incorrect conditions.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|05:32&lt;br /&gt;
|A good '''program''' should be '''readable'''. So others can extend and improve it. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|05:39&lt;br /&gt;
|'''Code''' is read more often than it is written.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|05:43&lt;br /&gt;
|We choose a name so that it becomes easier to understand its usage.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|05:49&lt;br /&gt;
| As we can see in the example, it is very easy to understand what the '''code''' is doing.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|05:55&lt;br /&gt;
|Proper naming helps so much in understanding the '''code.'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|06:00&lt;br /&gt;
|Also one should keep in mind the following things while writing a '''code''' in Python. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|06:06&lt;br /&gt;
| '''Four Space Indentation '''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|06:09&lt;br /&gt;
|79 characters limit on a line &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|06:13&lt;br /&gt;
|'''Functions''' and '''methods''' should be separated with two blank lines.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|06:18&lt;br /&gt;
| Use '''Docstring''' to document a specific segment of code. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|06:23&lt;br /&gt;
| Use '''whitespace''' around '''operators''' and after punctuations.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|06:28&lt;br /&gt;
|This brings us to the end of this tutorial. Let us summarize. &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|06:34&lt;br /&gt;
|In this tutorial, we have learnt to,&lt;br /&gt;
&lt;br /&gt;
Create simple '''tests''' for a '''function '''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|06:40&lt;br /&gt;
|'''Automate tests''' using many '''predefined test cases''' and Use '''python coding standards.'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|06:49&lt;br /&gt;
|Here is a self assessment question for you to solve &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|06:53&lt;br /&gt;
|What is the proper indentation for '''python code''' according to the '''style''' guidelines?&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|06:59&lt;br /&gt;
|And the answer,  Four Space Indentation is required for writing a python code according to the style guidelines.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|07:08&lt;br /&gt;
|Please post your timed queries in this forum.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|07:12&lt;br /&gt;
|Please post your general queries on Python in this forum.&lt;br /&gt;
&lt;br /&gt;
FOSSEE team coordinates the TBC project.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|07:22&lt;br /&gt;
|Spoken Tutorial Project is funded by NMEICT, MHRD, Govt. of India. For more details, visit this website.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|07:33&lt;br /&gt;
|This is Priya from IIT Bombay signing off. Thanks for watching.&lt;/div&gt;</summary>
		<author><name>PoojaMoolya</name></author>	</entry>

	</feed>