top of page
Search

Module_9

  • Writer: Angela Porcelli
    Angela Porcelli
  • Mar 12, 2021
  • 3 min read

Updated: Mar 15, 2021

Original data: Test your code from Module # 8 by using 1) https://www.onlinegdb.com/online_python_debugger and 2) unittest.TestCase function.


I find the online debugger to be much easier than writing a unittest for my code although, I'm not sure if it is as through in finding bugs in the code.


Repeat: After running my code through the online debugger, I received the following output and assume that it doesn't contain any bugs.

/home/main.py(1)<module>()

-> import itertools

(Pdb) continue

{'Cassanova', 'Foxy Fenny', 'Lightning'}

{'Cassanova', 'Foxy Fenny', 'Lightning'}

{'Cassanova', 'Foxy Fenny', 'Lightning'}

{'Cassanova', 'Foxy Fenny', 'Lightning'}

{'Cassanova', 'Foxy Fenny', 'Lightning'}

The program finished and will be restarted


I attempted a unit test for this code but received an error message due to the unit test code.


Cycle: After running my code through the online debugger, I received the following output and assume that it doesn't contain any bugs.

Lightning

Foxy Fenny

Cassanova

Lightning

Foxy Fenny

Cassanova

Lightning

Foxy Fenny

Cassanova

Lightning

Foxy Fenny

Cassanova

Lightning

Foxy Fenny

Cassanova

Lightning

Foxy Fenny

Cassanova

Lightning

Foxy Fenny

Cassanova

Lightning

Foxy Fenny

Cassanova

Lightning

Foxy Fenny


Deep Copy: After running my code through the online debugger, I received the following output and assume that it doesn't contain any bugs.

> /home/main.py(1)<module>()

-> import itertools

(Pdb) continue

['Mary', 'Siracha', 'Tilly', 'Andy']

['Squeak', 'Siracha', 'Tilly', 'Andy']

['Squeak', 'Siracha', 'Tilly', 'Andy']

The program finished and will be restarted


Soft Copy: After running my code through the online debugger, I received the following output and assume that it doesn't contain any bugs.

> /home/main.py(1)<module>()

-> import copy

(Pdb) continue

[['Squeak', 'Siracha'], ['Tilly', ['Bun Bun']]]

[['Squeak', 'Siracha'], ['Tilly', ['Bun Bun']]]

[['Squeak', 'Siracha'], ['Tilly', ['Bun Bun']]]

The program finished and will be restarted


Infinite: After running my code through the online debugger, I received the following output and assume that it doesn't contain any bugs.

> /home/main.py(1)<module>()

-> import itertools

(Pdb) continue

4 8 12 16 20 24 28 32 36 40 44 48 The program finished and will be restarted


I tried creating a unittest for this code but I kept getting an error message. The unit test code that I am writing is failing the unittest.


Chain: After running my code through the online debugger, I received the following output and assume that it doesn't contain any bugs.

> /home/main.py(1)<module>()

-> import itertools

(Pdb) continue

Siracha

Squeak

Chixpea

Pumpkin

Cannoli

Bean Sprout

Pinto

Goblin

Lima

Tilly

Bun Bun

Petunia

Andy

Gertrude

Mary

The program finished and will be restarted



I found the unittest function to be overly difficult when testing a chain. My first approach to this task was to see if a name found within my chain would provide a correct assertTrue output, however, I could not get this type of test to run. Unittest consistently provided error messages and would not run the test, so I figured I needed to break down the task. I decided to run an assertTrue unittest asking if a specific element was assigned to a specific variable. Again, I consistently ran into error messages preventing the function from running the unittest. Once again, I decided to break down the task. This time I equated the variables to objects, then ran unittest to see if the elements assigned to the variable/object would assertTrue. I was again met with error lines since the unittest could not return a decision on multiple elements. For example my original code is


Rabbits = {"Bun Bun", "Petunia", "Tilly", "Andy"}


However, the assertTrue unittest could not run


def test_Variable_Assign2(self): Rabbits=object self.assertTrue(Rabbits(),"Bun Bun", "Petunia", "Tilly", "Andy")

and instead need a separate test for each element. After running the tests, I realized that the only thing that assertTrue unittest was validating was that the elements were callable to an object, not that they had been assigned to the object. This was not helpful in determining if my code was correct since an element that was not present in the original code could be assigned to an object and therefore pass the assertTrue unittest. For example, my original code only list 'Mary' as an element of the variable Mouse, however, in the unittest, I was able to input 'Rain' and still receive an OK output.


def test_Variable_Assign7(self): Mouse=object self.assertTrue(Mouse(),'Rain')


I'm sure the issue lies in the way I have coded the unittest, but it does not seem to be an easy or intuitive function to work with. I'm surprised that after importing a module to the unittest, it cannot confirm that an element is equated to the module.





 
 
 

Recent Posts

See All
Final_Project

Problem description: The goal of graduating with a college degree is to have the ability to choose an employer that will provide an...

 
 
 

Comments


Post: Blog2_Post
  • Facebook
  • Twitter
  • LinkedIn

©2021 by LIS 5937 - Python for Data Science Professions. Proudly created with Wix.com

bottom of page