1 please write a python 3 program and show all outputs please separate files also se 5148678
1. Please write a python 3 program and show all outputs.
PLEASE SEPARATE FILES ALSO SEE EXAMPLE OF PART ONE BELOW.
Complete the TODOs in waterregulation/controller.py and waterregulation/decider.py.
Complete the TODOs in waterregulation/test.py and waterregulation/integrationtest.py. A single integration test may be sufficient. However, your unit tests in test.py should include at least one test for each specified behavior.
python -m unittest waterregulation/test.py and python -m unittest waterregulation/integrationtest.py should have no failures.
Running coverage run –source=waterregulation/controller.py,waterregulation/decider.py -m unittest waterregulation/test.py; coverage report shows 90%+ coverage..
Satisfy the linter such that pylint waterregulation gives no errors and and flake8 waterregulation gives no errors. You may have to add docstrings to your test files.
______________________________________________________________________________________________________________________
Example Test for this program from part one. This is only an example of orginal instructions and output code.
Original Instructions
python -m unittest integration-test should have no failures. Don't edit integration-test.py, edit your code to make it pass.
Add unit tests to unit-test.py such that coverage run –source=calculator -m unittest unit-test; coverage report shows 100% coverage.
All of the tests in unit-test.py should pass.
Satisfy the linter such that pylint calculator gives no errors and flake8 calculator gives no errors. See (PEP257)[https://www.python.org/dev/peps/pep-0257/] if you'd like more information about docstrings. There are quite a few docstrings to add, but for this exercise you don't need to get too creative: “”” this method adds two numbers “”” is sufficient.
Bonus goal
One of our specs for calculator says the following:
The add, subtract, multiply, and divide methods shall both:
Return the result of the operation
Enter the result of the operation back into the calculator
This makes it possible to perform the following sequences of operations:
calculator.enter_number(2)
calculator.enter_number(3)
calculator.add() # Returns 5, and now 5 is now 'in the calculator'
calculator.enter_number(1)
calculator.subtract() # Returns 4 because 5 – 1 = 4
_______________________________________________________________________________________________________
calculatorfuctions.py
“””calculator functions”””
def add(x, y):
“”” Add two numbers
>>> add(1, 2)
3
>>> add(-7, 2)
-5
“””
return int(x) + int(y)
__________________________
calculatorusage.py
#!/usr/bin/env python3
“””calculator
Usage:
calculator.py 1 + 3
“””
____________________________
calculator_test.sh.py
#!/bin/bash
test1=”2 + 3″
test2=”2 – 3″
___________________________________
calculator_test_suit.py
import unittest
from test_calculator import TestCalculatorFunctions
suite = unittest.TestLoader().loadTestsFromTestCase(TestCalculatorFunctions)
unittest.TextTestRunner(verbosity=2).run(suite)
______________________________________________
test_calculator.py
import unittest
import calculator_functions as calc
________________________________________________
test_calculator_pytest.py
#!/use/bin/env python
“””
tests for the calculator module
designed to be run with pytest
“””
import pytest
import calculator_functions as calc
# a very simple test
def test_add():
assert calc.add(2, 3) == 5
# testing with a variety of parameters:
def test_multiply_ugly():
“””
the ugly, not very robust way….
“””
assert calc.multiply(2, 2) == 4
assert calc.multiply(2, -1) == -2
assert calc.multiply(-2, -3) == 6
assert calc.multiply(3, 0) == 0
assert calc.multiply(0, 3) == 0
param_names = “arg1, arg2, result”
params = [(2, 2, 4),
(2, -1, -2),
(-2, -2, 4),
(3, 0, 0),
]
@pytest.mark.parametrize(param_names, params)
def test_multiply(arg1, arg2, result):
assert calc.multiply(arg1, arg2) == result