----BEGIN CLASS---- [13:39] #startclass [13:39] Roll Call [13:39] Gaurav Sitlani [13:39] Ashwani Kumar Gupta [13:40] Soumam Banerjee [13:40] Bhavin Gandhi [13:40] Sandesh Patel [13:40] Krishnanand Rai [13:40] Anu kumari Gupta [13:41] Good evening kushal [13:43] Who all read the chapter https://pymbook.readthedocs.io/en/latest/testing.html ? [13:44] Anyone? [13:45] Today we can discuss about the chapter, if you all want. [13:45] Or we can try to write some other code too. [13:46] kushal, I didn't read this but I tried unittest module before [13:46] i am going through it, sure we can discuss about it. [13:46] Anyone else? [13:46] kushal, I'm reading that chapter now [13:47] Okay, everyone please start reading the chapter. [13:51] yeah got the idea [13:54] kushal, https://pymbook.readthedocs.io/en/latest/testing.html#mounttab-py - shouldn't mounttab2 be mounttab here? [13:55] oh that's new file. got it [13:59] Is there any metric for good test cases? [14:00] ashwanig, metric means? [14:00] Gajanan More [14:00] ashwanig, Also good depends on usecase. [14:00] Can anyone tell me why do we at all write these tests? [14:01] kushal, metric == standard of measurement [14:01] to identify errors [14:01] may be kushal in the typical regions [14:02] like boundary conditions [14:02] kushal, to maintain the expected functionality [14:02] so that when new changes are brought in, they behave as expected [14:03] To ensure that functions work as expected even after making some changes to them [14:05] to check for the behavioural changes in function [14:05] What is the meaning of test? [14:05] kushal, evaluation of something [14:06] checking [14:07] kushal: to ensure that the function provide required result [14:08] kushal: checking that things are working correctly [14:09] measuring degree of correctness [14:09] a procedure intended to establish the quality, performance, or reliability of something, especially before it is taken into widespread use. [14:10] in simple words criteria for acceptance or rejection for something [14:12] what i got is that it simply evaluates by checking and if it fails it shows that [14:13] pycharm has a nice interface for implementing testing [14:14] So, testing means to check if something is working as we expect it to work. [14:14] That means, we have to first determine how it should work, for some particular input, what will be the output. [14:15] That matters the most, unless you know how something works, you can not test that particular project. [14:17] ! [14:17] next [14:17] what we are referring to is white box testing right ? [14:18] I am talking about real life. [14:18] gauravsitlani, like if you put the key in the right place in the car, and turn clock wise, it should start the engine. [14:29] kushal: are you there ? [14:36] gauravsitlani, yes [14:36] tell me [14:37] i got your point, you were telling about real life tests [14:38] gauravsitlani, now think the same about testing software. [14:39] gauravsitlani, Unless you know how to use a software, you can not test it. [14:42] ! [14:47] kushal tell me a thing , when we are evaluating ourself first then we are writing test and then we understand weather the test is passing or not. I mean whats the use when we are calculating manually first. We can directly check by running our program itself . Right? [14:49] kushal : there's an extra closing bracket in line : print()'%s on %s type %s' % (words[0],words[1],words[2]), end=' ') under mounttab.py [14:49] soumam007, but when the project is big, then it will be a big task to check everything manually [14:50] my thoughts [14:51] but ashwanig you are doing it manually [14:51] Also is it that when we are testing we know the output or the correct answer of a computation beforehand? [14:51] beacuse in factorial you manually calculate it first and then rquate it with your output of your test [14:52] soumam007, we are doing it using a program [14:52] we can run all tests by running a single command [14:54] anuGupta, yes, we compare the actual output with expected output [14:54] ashwanig, who gives us the expected output in factorial.py? [14:55] soumam007, self.assertEqual(res, 120) [14:55] 120 is expected [14:55] i guess we need to calculate it ourself and then self.assertEqual(res, 120) [14:56] so this is a small program we can calculate our expected value [14:56] but whats if the program is huge [14:56] soumam007, manually yes [14:56] soumam007, we can do it once, but written tests help us to automate it. [14:58] ! [14:58] anuGupta , you have added in queue. Wait for your turn. [14:58] so in that case also kushal we are giving our expected value [14:59] though automated means it should check of its own ? [15:00] next [15:00] next [15:00] soumam007, isn't that a test is doing? [15:00] What else can we do to test other than the assert methods ?Are these assert statements the only way to test? [15:01] ok kushal , i need to write it to have benefits from it :P [15:01] anuGupta, Generally yes, we write those assert methods to verify things. [15:02] Can I give you a simple test to write? [15:02] Ok [15:02] you == you all? [15:02] a simple one [15:02] Yes [15:02] ok [15:04] write a test case, which will tell us if a file "/tmp/dgplug.txt" exists or not. [15:04] It should fail if the file is not there on disk. [15:10] kushal, https://paste.fedoraproject.org/paste/8YRNcZdaui1fPAVQMLGIKQ [15:11] ashwanig, checking [15:11] ashwanig, can we make it simpler? [15:11] like [15:12] using open() ? [15:12] self.assert(os.path.exists(filepath)) type? [15:13] yes [15:13] True not needed? [15:16] this works self.assertTrue(os.path.exists(filepath)) [15:21] kushal: https://paste.fedoraproject.org/paste/LiONJjPbetUVjT7eq-rqZA : test.py [15:21] ashwanig, yup [15:21] gauravsitlani, checking [15:21] https://paste.fedoraproject.org/paste/0EVpPYtbkDJ-Gyg0roi9TQ : test_1.py [15:21] i have used 2 files [15:22] gauravsitlani, yes, too much hard work :) [15:22] gauravsitlani, you opened a file, never closed it :( [15:22] oops [15:22] kushal: http://paste.ubuntu.com/25720779/ [15:23] will make the changes [15:24] kushal: https://paste.fedoraproject.org/paste/TKp66rvR2fVFc93FYMC3yA : test_1.py [15:26] https://paste.fedoraproject.org/paste/OwOtXuq9wZouiKqpHkSN6A [15:26] kushal, ^^^^ [15:26] https://paste.fedora.org/paste/yrHTVeS6GBJV~UZBjfAakA [15:27] https://paste.fedoraproject.org/paste/yrHTVeS6GBJV~UZBjfAakA [15:28] got to go for dinner , will check out the logs. Bye everyone :) [15:28] bye gauravsitlani have a nice dinner :P [15:29] ending the session here, I will check the answer after 10:30pm [15:30] ok [15:33] Sorry, this is final https://paste.fedoraproject.org/paste/QfmzegkKn-BKotRN2hbSoA [15:37] oops final ---> https://paste.fedoraproject.org/paste/UpKlBTBw2bG-Jdrf0XgbAg ----END CLASS----