Example #1
0
def main():
    # type: () -> ExitStatus
    """Accept arguments from the user, compute the factorial, and display the results."""
    colorama.init(autoreset=True, strip=False)
    args = parse_args()

    print('fact({}{}{}) = {}{}{}'.format(colorama.Fore.CYAN, args.n,
                                         colorama.Fore.RESET,
                                         colorama.Fore.GREEN,
                                         factorial(args.n),
                                         colorama.Fore.RESET))
    return ExitStatus.success
Example #2
0
def test_factorial(n, expected):
    # type: (int, int) -> None
    assert factorial(n) == expected
Example #3
0
def test_invalid_factorial(n):
    # type: (int) -> None
    with pytest.raises(InvalidFactorialError):
        factorial(n)
Example #4
0
def test_invalid_factorial(n: int) -> None:
    with pytest.raises(InvalidFactorialError):
        factorial(n)
Example #5
0
def test_factorial(n: int, expected: int) -> None:
    assert factorial(n) == expected