Module pedantic.tests.tests_main

Functions

def run_all_tests() ‑> None
Expand source code
def run_all_tests() -> None:
    test_classes_to_run = [
        TestAssertValueMatchesType,
        TestGenericMixin,
        TestWithDecoratedMethods,
        TestRequireKwargs,
        TestClassDecorators,
        TestContextManager,
        TestFrozenDataclass,
        TestPedanticClass,
        TestDecoratorRequireKwargsAndTypeCheck,
        TestSmallDecoratorMethods,
        TestCombinationOfDecorators,
        TestRequireDocstringGoogleFormat,
        TestPedanticClassDocstring,
        TestDecoratedFunction,
        TestEnvironmentVariables,
        TestGenericClasses,
        TestGenerator,
        TestMock,
        TestGeneratorWrapper,
        TestRenameKwargs,
        TestRetry,
        TestRetryFunc,
        TestResolveForwardRef,
        # validate
        TestValidatorDatetimeIsoformat,
        TestFlaskParameters,
        TestParameterEnvironmentVariable,
        TestConvertValue,
        TestValidate,
        TestValidatorComposite,
        TestValidatorDatetimeUnixTimestamp,
        TestValidatorEmail,
        TestValidatorForEach,
        TestValidatorIsEnum,
        TestValidatorIsUUID,
        TestValidatorMatchPattern,
        TestValidatorMax,
        TestValidatorMaxLength,
        TestValidatorMin,
        TestValidatorMinLength,
        TestValidatorNotEmpty,

        # async
        AsyncValidateTests,
        AsyncSmallDecoratorTests,
        TestPedanticAsyncio,
        TestInSubprocess,
        TestAsyncContextManager,

        TestPedanticPython311AddedStuff,
    ]

    loader = unittest.TestLoader()
    suites_list = [get_doctest_test_suite()]

    for test_class in test_classes_to_run:
        suite = loader.loadTestsFromTestCase(test_class)
        suites_list.append(suite)

    big_suite = unittest.TestSuite(suites_list)
    runner = unittest.TextTestRunner()
    result = runner.run(big_suite)
    assert not result.errors and not result.failures, f'Some tests failed!'