示例#1
0
    def test_multiplication(self):
        """
		Test the multiplication of two numbers
		"""
        calculator = Calculator()
        calculator.number(number=9)
        log.debug(calculator)
        calculator.operation(operation='*')
        log.debug(calculator)
        calculator.number(number=3)
        log.debug(calculator)
        calculator.equal()
        log.debug(calculator)
        self.assertEqual(calculator.display, '27')
示例#2
0
    def test_division(self):
        """
		Test the division of two numbers
		"""
        calculator = Calculator()
        calculator.number(number=9)
        log.debug(calculator)
        calculator.operation(operation='/')
        log.debug(calculator)
        calculator.number(number=3)
        log.debug(calculator)
        calculator.equal()
        log.debug(calculator)
        self.assertEqual(calculator.display, '3')
示例#3
0
    def test_number_reset(self):
        """
		Test number and reset
		"""
        calculator = Calculator()
        log.debug(calculator)
        calculator.number(number=4)
        log.debug(calculator)
        calculator.number(number=2)
        log.debug(calculator)
        calculator.reset()
        self.assertEqual(calculator.display, '0')
示例#4
0
    def test_add_equal(self):
        """
		Test the add with equal
		"""
        calculator = Calculator()
        calculator.number(number=9)
        log.debug(calculator)
        calculator.operation(operation='+')
        log.debug(calculator)
        calculator.number(number=3)
        log.debug(calculator)
        calculator.equal()
        log.debug(calculator)
        self.assertEqual(calculator.display, '12')
        calculator.equal()
        self.assertEqual(calculator.display, '15')
示例#5
0
    def test_subtraction(self):
        """
		Test the subtraction of two numbers
		"""
        calculator = Calculator()
        log.debug(calculator)
        calculator.number(number=4)
        log.debug(calculator)
        calculator.number(number=2)
        log.debug(calculator)
        calculator.operation(operation='-')
        log.debug(calculator)
        calculator.number(number=3)
        log.debug(calculator)
        calculator.number(number=3)
        log.debug(calculator)
        calculator.number(number=3)
        log.debug(calculator)
        calculator.equal()
        log.debug(calculator)
        self.assertEqual(calculator.display, '-291')
示例#6
0
    def test_add_equal_multiply_reset_division(self):
        """
		Test addition, equal, multiply, reset, division
		"""
        calculator = Calculator()
        log.debug(calculator)
        calculator.number(number=4)
        log.debug(calculator)
        calculator.number(number=2)
        log.debug(calculator)
        calculator.operation(operation='+')
        log.debug(calculator)
        calculator.number(number=3)
        log.debug(calculator)
        calculator.number(number=3)
        log.debug(calculator)
        calculator.number(number=3)
        log.debug(calculator)
        calculator.equal()
        log.debug(calculator)
        self.assertEqual(calculator.display, '375')

        calculator.number(number=4)
        log.debug(calculator)
        calculator.number(number=2)
        log.debug(calculator)
        calculator.operation(operation='*')
        log.debug(calculator)
        calculator.reset()
        self.assertEqual(calculator.display, '0')

        calculator.number(number=9)
        log.debug(calculator)
        calculator.operation(operation='/')
        log.debug(calculator)
        calculator.number(number=3)
        log.debug(calculator)
        calculator.equal()
        log.debug(calculator)
        self.assertEqual(calculator.display, '3')
示例#7
0
    def test_add_equal_multiply_equal(self):
        """
		Test addition, equal, multiply, equal
		"""
        calculator = Calculator()
        log.debug(calculator)
        calculator.number(number=4)
        log.debug(calculator)
        calculator.number(number=2)
        log.debug(calculator)
        calculator.operation(operation='+')
        log.debug(calculator)
        calculator.number(number=3)
        log.debug(calculator)
        calculator.number(number=3)
        log.debug(calculator)
        calculator.number(number=3)
        log.debug(calculator)
        calculator.equal()
        log.debug(calculator)
        self.assertEqual(calculator.display, '375')
        calculator.number(number=4)
        log.debug(calculator)
        calculator.number(number=2)
        log.debug(calculator)
        calculator.operation(operation='*')
        log.debug(calculator)
        calculator.number(number=3)
        log.debug(calculator)
        calculator.equal()
        self.assertEqual(calculator.display, '126')
示例#8
0
    def test_add(self):
        """
		Test the addition of two numbers
		"""
        calculator = Calculator()
        log.debug(calculator)
        calculator.number(number=4)
        log.debug(calculator)
        calculator.number(number=2)
        log.debug(calculator)
        calculator.operation(operation='+')
        log.debug(calculator)
        calculator.number(number=3)
        log.debug(calculator)
        calculator.number(number=3)
        log.debug(calculator)
        calculator.number(number=3)
        log.debug(calculator)
        calculator.equal()
        log.debug(calculator)
        self.assertEqual(calculator.display, '375')
示例#9
0
    def test_precedence_add_multiply_subtraction_division(self):
        '''
		Test precedence by adding, multiplying, subtraction, division
		'''
        calculator = Calculator()
        log.debug(calculator)
        calculator.number(number=9)
        log.debug(calculator)
        calculator.operation(operation='+')
        log.debug(calculator)
        calculator.number(number=5)
        log.debug(calculator)
        calculator.operation(operation='*')
        log.debug(calculator)
        calculator.number(number=2)
        log.debug(calculator)
        calculator.operation(operation='-')
        log.debug(calculator)
        calculator.number(number=9)
        log.debug(calculator)
        calculator.operation(operation='/')
        log.debug(calculator)
        calculator.number(number=2)
        log.debug(calculator)
        calculator.equal()
        log.debug(calculator)
        self.assertEqual(calculator.display, '14.5')
示例#10
0
    def test_precedence_add_multiply(self):
        '''
		Test precedence by adding and multiplying
		'''
        calculator = Calculator()
        log.debug(calculator)
        calculator.number(number=9)
        log.debug(calculator)
        calculator.operation(operation='+')
        log.debug(calculator)
        calculator.number(number=5)
        log.debug(calculator)
        calculator.operation(operation='*')
        log.debug(calculator)
        calculator.number(number=2)
        log.debug(calculator)
        calculator.equal()
        log.debug(calculator)
        self.assertEqual(calculator.display, '19')