Skip to content
Snippets Groups Projects
Select Git revision
  • branche-avec-truc-style
  • master default
  • 2023
  • branche-a-rebase
4 results

fichier_inutile

Blame
  • test_calculator.py 1.14 KiB
    """
    Test module for the calculator module.
    """
    import pytest
    from calculator.calculator import Calculator
    from calculator.operators import Operator
    
    
    @pytest.fixture(scope="module", name="setup")
    def fixture_setup():
        """
        Setup the test suite, by instantiating the calculator and the operators.
        """
        plus = Operator('+', 1, lambda a, b: a + b)
        minus = Operator('-', 1, lambda a, b: a - b)
        times = Operator('*', 2, lambda a, b: a * b)
        divide = Operator('/', 2, lambda a, b: a / b)
        calculator = Calculator(
            operators={'+': plus, '-': minus, '*': times, '/': divide})
        yield plus, minus, times, divide, calculator
    
    
    def test_tokenizer(setup):
        """
        Test the tokenizer.
        """
        plus, minus, times, divide, calc = setup
        # À toi de tester la fonction tokenize de Calculator.
    
    
    def test_parser(setup):
        """
        Test the parser.
        """
        plus, minus, times, divide, calc = setup
        # À toi de tester la fonction parse de Calculator.
    
    
    def test_evaluation(setup):
        """
        Test the evaluation.
        """
        plus, minus, times, divide, calc = setup
        # À toi de tester la fonction __call__ de Calculator.