Package: assertify
assertifyassertify -- assert or (ver)ify -- is a Flexible, and Extendable python3.6+ library for evaluating an expression by returningFalseor raising anAssertionErroror the givenExceptionif the expression is invalid.Key Features:Easy: Designed to make it easy to evaluate an expression and returnTrue/Falseor raise anAssertionErrororException.Great Developer Experience: Being fully typed makes it great for editor support.There is More!!!:unittest_assertions: Assertify is built on top of theunittest_assertions, which is a library that converts the assertions fromunittestto standalone assertions.InstallationpipinstallassertifyExampleraises an appropriate exception by default.Exception ExampleAssertifyIsInstancewill raise aTypeErrorby default, but you can also specify any other type of exception.fromassertifiers.identityimportAssertifyIsInstanceis_instance=AssertifyIsInstance()is_instance("example str",int)# raise TypeError("'example str' is not an instance of <class 'int'>")Assertion ExampleSpecifyAssertionErrorto be raisedfromassertifiers.identityimportAssertifyIsInstanceis_instance=AssertifyIsInstance(raises=AssertionError)is_instance("example str",int)# raise AssertionError("'example str' is not an instance of <class 'int'>")Boolean ExampleIfraises=Noneassertify will return aBoolean.fromassertifiers.identityimportAssertifyIsInstanceis_instance=AssertifyIsInstance(raises=None)print(is_instance("example str",int))# FalsePredicate (Partial Function) Examplefromfunctoolsimportpartialfromassertifiers.identityimportAssertifyIsInstancesis_instance=AssertifyIsInstances(must_be_instance_of=any)predicate_is_instance=partial(is_instance,classes=[int,float])print(predicate_is_instance(obj=7.62))# TrueAssertifiersComparisonAssertifierExpressionraisesAssertifyEqualassertifyfirst == secondValueErrorAssertifyNotEqualassertifyfirst != SecondValueErrorAssertifyAlmostEqualassertifyfirst ~= secondValueErrorAssertifyNotAlmostEqualassertifyfirst !~= secondValueErrorAssertifyCountEqualassertifylen(first) == len(second)ValueErrorAssertifyMultilineEqualassertifyfirst.splitlines() == second.splitlines()ValueErrorAssertifySequenceEqualassertifyseq1 == seq2ValueErrorAssertifyListEqualassertifylist1 == list2ValueErrorAssertifyTupleEqualassertifytuple1 == tuple2ValueErrorAssertifySetEqualassertifyset1 == set2ValueErrorAssertifyDictEqualassertifydict1 == dict2ValueErrorAssertifyLessassertifya < bValueErrorAssertifyLessEqualassertifya <= bValueErrorAssertifyGreaterassertifya > bValueErrorAssertifyGreaterassertifya >= bValueErrorContainerAssertifierExpressionraisesAssertifyInassertifymember in containerValueErrorAssertifyNotInassertifymember not in containerValueErrorControlAssertifierExpressionraisesAssertifyRaisesassertifyfunction raises expected_exceptionValueErrorAssertifyWarnsassertifyfunction warns expected_warningValueErrorAssertifyLogsassertifylogger(level)ValueErrorIdentityAssertifierExpressionraisesAssertifyIsassertifyexp1 is exp2ValueErrorAssertifyIsNotassertifyexp1 is not exp2ValueErrorAssertifyIsNoneassertifyobj is NoneValueErrorAssertifyIsNotNoneassertifyobj is not NoneValueErrorAssertifyIsInstanceassertifyisinstance(obj,class)TypeErrorAssertifyIsInstancesassertifyisinstance(obj,cls) for cls in classesTypeErrorAssertifyIsNotInstanceassertifynot isinstance(obj,class)TypeErrorAssertifyIsNotInstancesassertifynot isinstance(obj,cls) for cls in classesTypeErrorLogicAssertifierExpressionraisesAssertifyTrueassertifyexpr is TrueValueErrorAssertifyFalseassertifyexpr is FalseValueErrorRegexAssertifierExpressionraisesAssertifyRaisesRegexassertifyexpected_regex in expected_exception_messageValueErrorAssertifyWarnsRegexassertifyexpected_regex in expected_warning_messageValueErrorAssertifyRegexassertifytext in expected_regexValueErrorAssertifyNotRegexassertifytext not in expected_regexValueError