r0meroh / Unittests_in_python

Small program that includes pythonic implementations of classes, objects, inheratince, and unittests.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unittests_in_python

Small program that includes pythonic implementations of classes, objects, inheratince, and unittests.

directory

The names.py is the object class that includes only a first name and a last name. Name class includes a fillin function to return variables for logical operations. Also the str function returns the formatted string when a name object is printed instead of the default object's bytecode.

names

loops.py includes a function loop that utilizes names.py to create name objects and name them independantly for later purposes if need be. This is important because normally, unless modified, objects created in loops are unnamed and generic making it difficut to access created objects after the loop is completed. The object variables are stored within independent lists that run in parallel.

loop

Inherited from names.py is name_with_middle which inludes the addition of a middle name.

name_with_middle

Other additions to the names_with_middle is the fillin function and str functions.

additions

loop_with_middle is a modified instance of the original loop() to accommodate the additional functionality of the name_with_middle object.

loop_with_middle

format_a_name.py takes in both types of objects and returns a formatted string to be printed out. This is accomplished by making two of the arguments in the function parameters be empty default strings.

format

The main class handles both types of objects differently. For the names.py class it uses polymorphism to create a dictionary of first names as keys and last names as values. For the names_with_middle , all three parallel lists are passed into the function.

main

finally, we test both objects using unittests.

test

About

Small program that includes pythonic implementations of classes, objects, inheratince, and unittests.


Languages

Language:Python 100.0%