Ejemplo n.º 1
0
 def setUp(self):
     """Set up for calc tests so don't have to rewrite"""
     self.adder = Adder()
     self.subtracter = Subtracter()
     self.multiplier = Multiplier()
     self.divider = Divider()
     # Line is too long, but whatever.
     self.calculator = Calculator(self.adder, self.subtracter, self.multiplier, self.divider)
Ejemplo n.º 2
0
    def setUp(self):
        self.adder = Adder()
        self.subtracter = Subtracter()
        self.multiplier = Multiplier()
        self.divider = Divider()

        self.calculator = Calculator(self.adder, self.subtracter,
                                     self.multiplier, self.divider)
Ejemplo n.º 3
0
    def setUp(self):
        """setup for calculator tests"""
        self.adder = Adder()
        self.subtracter = Subtracter()
        self.multiplier = Multiplier()
        self.divider = Divider()

        self.calculator = Calculator(self.adder, self.subtracter,
                                     self.multiplier, self.divider)
Ejemplo n.º 4
0
    def setUp(self):
        """Method doc string."""
        self.adder = Adder()
        self.subtracter = Subtracter()
        self.multiplier = Multiplier()
        self.divider = Divider()

        self.calculator = Calculator(self.adder, self.subtracter,
                                     self.multiplier, self.divider)
    def setUp(self):
        """Test case that setups the other test cases from range -10 to 10"""
        self.adder = Adder()
        self.subtracter = Subtracter()
        self.multiplier = Multiplier()
        self.divider = Divider()

        self.calculator = Calculator(self.adder, self.subtracter,
                                     self.multiplier, self.divider)
def main():

    adder = Adder()
    subtracter = Subtracter()
    multiplier = Multiplier()
    divider = Divider()

    calculator = Calculator(adder, subtracter, multiplier, divider)
    return calculator
Ejemplo n.º 7
0
    def setUp(self):
        """Initialize calculator with new operator objects."""
        self.adder = Adder()
        self.subtracter = Subtracter()
        self.multiplier = Multiplier()
        self.divider = Divider()

        self.calculator = Calculator(self.adder, self.subtracter,
                                     self.multiplier, self.divider)
Ejemplo n.º 8
0
    def setUp(self):
        """Initializes the calculator"""
        self.adder = Adder()
        self.subtracter = Subtracter()
        self.multiplier = Multiplier()
        self.divider = Divider()

        self.calculator = Calculator(self.adder, self.subtracter,
                                     self.multiplier, self.divider)
Ejemplo n.º 9
0
    def setUp(self):
        """Provide a method to run each time before any test method is run."""
        self.adder = Adder()
        self.subtracter = Subtracter()
        self.multiplier = Multiplier()
        self.divider = Divider()

        self.calculator = Calculator(self.adder, self.subtracter,
                                     self.multiplier, self.divider)
Ejemplo n.º 10
0
    def setUp(self):
        """ 1 time setup with modules """

        self.adder = Adder()
        self.subtracter = Subtracter()
        self.multiplier = Multiplier()
        self.divider = Divider()

        self.calculator = Calculator(self.adder, self.subtracter,
                                     self.multiplier, self.divider)
Ejemplo n.º 11
0
    def setUp(self):
        """
        This method initializes variables
        """
        self.adder = Adder()
        self.subtracter = Subtracter()
        self.multiplier = Multiplier()
        self.divider = Divider()

        self.calculator = Calculator(self.adder, self.subtracter,
                                     self.multiplier, self.divider)
Ejemplo n.º 12
0
	def test_module(self):
		calculator = Calculator(Adder(), Subtracter(), Multiplier(), Divider())
		calculator.enter_number(5)
		calculator.enter_number(2)
		calculator.multiply()
		calculator.enter_number(46)
		calculator.add()
		calculator.enter_number(8)
		calculator.divide()
		calculator.enter_number(1)
		result = calculator.subtract()
		self.assertEqual(6, result)
Ejemplo n.º 13
0
    def setUp(self):
        """
        Fill the calculator object with proper adder, subtracter,
        multiplier, and divider classes.
        """
        self.adder = Adder()
        self.subtracter = Subtracter()
        self.multiplier = Multiplier()
        self.divider = Divider()

        self.calculator = Calculator(
            self.adder, self.subtracter, self.multiplier, self.divider)
Ejemplo n.º 14
0
    def setUp(self): #Run before test method is run
        """
        Setup
        """
        
        self.adder = Adder()
        self.subtracter = Subtracter()
        self.multiplier = Multiplier()
        self.divider = Divider()

        self.calculator = Calculator(self.adder, 
                                     self.subtracter, 
                                     self.multiplier, 
                                     self.divider)
Ejemplo n.º 15
0
    def test_module(self):
        '''Runs the actual integration test, going through all calculator calls
        and testing the end result'''

        calculator = Calculator(Adder(), Subtracter(), Multiplier(), Divider())
        calculator.enter_number(5)
        calculator.enter_number(2)
        calculator.multiply()
        calculator.enter_number(46)
        calculator.add()
        calculator.enter_number(8)
        calculator.divide()
        calculator.enter_number(1)
        result = calculator.subtract()
        assert result == 6
Ejemplo n.º 16
0
 def test_module(self):
     """
     Testing the calculator by calling each methods
     """
     calculator = Calculator(Adder(), Subtracter(), Multiplier(), Divider())
     calculator.enter_number(5)
     calculator.enter_number(2)
     calculator.multiply()
     calculator.enter_number(46)
     calculator.add()
     calculator.enter_number(8)
     calculator.divide()
     calculator.enter_number(1)
     result = calculator.subtract()
     self.assertEqual(6, result)
    def test_module_insufficient_operands(self):
        calculator = Calculator(Adder(), Subtracter(), Multiplier(), Divider())

        calculator.enter_number(5)
        calculator.enter_number(2)

        calculator.multiply()

        calculator.enter_number(46)

        calculator.add()

        calculator.enter_number(8)

        calculator.divide()

        with self.assertRaises(InsufficientOperands):
            calculator.subtract()
    def test_module_zero_division_error(self):
        calculator = Calculator(Adder(), Subtracter(), Multiplier(), Divider())

        calculator.enter_number(5)
        calculator.enter_number(2)

        calculator.multiply()

        calculator.enter_number(46)

        calculator.add()

        calculator.enter_number(8)

        calculator.subtract()

        calculator.enter_number(0)

        with self.assertRaises(ZeroDivisionError):
            calculator.divide()
Ejemplo n.º 19
0
    def test_module(self):
        """The first of... one test module(s). lol lazy."""
        calculator = Calculator(Adder(), Subtracter(), Multiplier(), Divider())

        calculator.enter_number(5)
        calculator.enter_number(2)

        calculator.multiply()

        calculator.enter_number(46)

        calculator.add()

        calculator.enter_number(8)

        calculator.divide()

        calculator.enter_number(1)

        result = calculator.subtract()

        self.assertEqual(6, result)
    def test_module(self):

        calculator = Calculator(Adder(), Subtracter(), Multiplier(), Divider())

        calculator.enter_number(5)
        calculator.enter_number(2)

        # Tests
        # Add:
        self.assertEqual(7, calculator.add())

        # Subtract:
        calculator.enter_number(5)
        self.assertEqual(2, calculator.subtract())

        # Multiply:
        calculator.enter_number(5)
        self.assertEqual(10, calculator.multiply())

        # Divide:
        calculator.enter_number(1)
        self.assertEqual(10, calculator.divide())
Ejemplo n.º 21
0
    def test_module(self):
        """ Tests each module against an expected output to ensure accuracy. """
        calculator = Calculator(Adder(), Subtracter(), Multiplier(), Divider())

        calculator.enter_number(5)
        calculator.enter_number(2)

        # Tests
        # Add:
        self.assertEqual(7, calculator.add())

        # Subtract:
        calculator.enter_number(5)
        self.assertEqual(2, calculator.subtract())

        # Multiply:
        calculator.enter_number(5)
        self.assertEqual(10, calculator.multiply())

        # Divide:
        calculator.enter_number(1)
        self.assertEqual(10, calculator.divide())
    def test_module(self):
        """Initializes the calculator, operates with various ints"""

        calculator = Calculator(Adder(), Subtracter(), Multiplier(), Divider())

        calculator.enter_number(5)
        calculator.enter_number(2)

        calculator.multiply()

        calculator.enter_number(46)

        calculator.add()

        calculator.enter_number(8)

        calculator.divide()

        calculator.enter_number(1)

        result = calculator.subtract()

        self.assertEqual(6, result)
    def test_module(self):
        """Tests all calculator modules."""

        calculator = Calculator(Adder(), Subtracter(), Multiplier(), Divider())

        calculator.enter_number(5)
        calculator.enter_number(2)

        calculator.multiply()  #10

        calculator.enter_number(46)

        calculator.add()  #56

        calculator.enter_number(8)

        calculator.divide()  #7

        calculator.enter_number(1)

        result = calculator.subtract()  #6

        self.assertEqual(6, result)  #Result should equal 6
    def test_module(self):
        """Test that calculator performs operations as expected"""

        calculator = Calculator(Adder(), Subtracter(), Multiplier(), Divider())

        calculator.enter_number(5)
        calculator.enter_number(2)

        calculator.multiply()

        calculator.enter_number(46)

        calculator.add()

        calculator.enter_number(8)

        calculator.divide()

        calculator.enter_number(1)

        result = calculator.subtract()

        self.assertEqual(6, result)
Ejemplo n.º 25
0
    def test_module(self):

        calculator = Calculator(Adder(), Subtracter(), Multiplier(), Divider())

        # STACK: []
        calculator.enter_number(5)
        calculator.enter_number(2)
        result = calculator.multiply()
        self.assertEqual(10, result)

        # STACK: [10]
        calculator.enter_number(46)
        result = calculator.add()
        self.assertEqual(56, result)

        # STACK: [56]
        calculator.enter_number(8)
        result = calculator.divide()
        self.assertEqual(7, result)

        # STACK: [7]
        calculator.enter_number(1)
        result = calculator.subtract()
        self.assertEqual(6, result)
Ejemplo n.º 26
0
    def test_module(self):
        """
        Tests all calculator modules work together nicely and the correct
        module is called for the given calculation operation.
        """
        calculator = Calculator(Adder(), Subtracter(), Multiplier(), Divider(),
                                Squarer())

        calculator.enter_number(2)
        calculator.square()  # result = 4

        calculator.enter_number(3)
        calculator.multiply()  # result = 12

        calculator.enter_number(8)
        calculator.add()  # result = 20

        calculator.enter_number(4)
        calculator.divide()  # result = 5

        calculator.enter_number(6)
        result = calculator.subtract()  # result = -1

        self.assertEqual(-1, result)
Ejemplo n.º 27
0
    def test_subtracting(self):
        subtracter = Subtracter()

        for i in range(-10, 10):
            for j in range(-10, 10):
                self.assertEqual(i - j, subtracter.calc(i, j))
Ejemplo n.º 28
0
from calculator.adder import Adder
from calculator.subtracter import Subtracter
from calculator.multiplier import Multiplier
from calculator.divider import Divider
from calculator.calculator import Calculator
from calculator.exceptions import InsufficientOperands

if __name__ == '__main__':
    add = Adder()
    sub = Subtracter()
    multi = Multiplier()
    div = Divider()
    test_1 = Calculator(add, sub, multi, div)
    test_1.enter_number(1)
    test_1.enter_number(2)

    temp_num = test_1.add()
    print(temp_num)