Skip to content

iw4p/python-OOP-unittest-design-pattern

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple and basic python Object oriented calculator with test and unittest - design pattern

Strategy is a behavioral design pattern that turns a set of behaviors into objects and makes them interchangeable inside original context object.

Usage examples: The Strategy pattern is very common in Python code. It’s often used in various frameworks to provide users a way to change the behavior of a class without extending it.

Identification: Strategy pattern can be recognized by a method that lets a nested object do the actual work, as well as a setter that allows replacing that object with a different one.

Run tests

Make sure you installed nose2

python -m nose2

Or basically run test files

python test_ ...... .py

Usage

For simple-oop:

calculator_object = Calculator()
calculator_object(5, 5, '+')

or

calculator_object = Calculator()
calculator_object.first_number = 5
calculator_object.second_number = 5
calculator_object.operation = '+'
calculator_object.calc()

for strategy-design-pattern:

calculator_object = Calculator()
calculator_object.first_number = 5
calculator_object.second_number = 5
calculator_object.operation = Sum_strategy()

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

License

MIT

About

basic OOP implementation - python calculator for learning test and design patterns

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages