Пример #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
Пример #2
0
def test_factorial(n, expected):
    # type: (int, int) -> None
    assert factorial(n) == expected
Пример #3
0
def test_invalid_factorial(n):
    # type: (int) -> None
    with pytest.raises(InvalidFactorialError):
        factorial(n)
Пример #4
0
def test_invalid_factorial(n: int) -> None:
    with pytest.raises(InvalidFactorialError):
        factorial(n)
Пример #5
0
def test_factorial(n: int, expected: int) -> None:
    assert factorial(n) == expected