{"id":15444751,"url":"https://github.com/tybruno/assertify","last_synced_at":"2025-08-06T10:18:51.034Z","repository":{"id":45378079,"uuid":"392399764","full_name":"tybruno/assertify","owner":"tybruno","description":"Simple, Flexible, and Extendable python3.6+ library for boolean expressions, assertions, and verifications.","archived":false,"fork":false,"pushed_at":"2021-12-16T21:13:00.000Z","size":101,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-04-26T13:46:48.058Z","etag":null,"topics":["assertions","boolean-expression","python","verifications","verify"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tybruno.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-08-03T17:28:50.000Z","updated_at":"2021-12-16T21:06:38.000Z","dependencies_parsed_at":"2022-09-19T08:50:56.436Z","dependency_job_id":null,"html_url":"https://github.com/tybruno/assertify","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tybruno%2Fassertify","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tybruno%2Fassertify/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tybruno%2Fassertify/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tybruno%2Fassertify/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tybruno","download_url":"https://codeload.github.com/tybruno/assertify/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245991585,"owners_count":20706129,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["assertions","boolean-expression","python","verifications","verify"],"created_at":"2024-10-01T19:42:27.894Z","updated_at":"2025-03-28T08:14:39.023Z","avatar_url":"https://github.com/tybruno.png","language":"Python","readme":"[![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-green.svg)](https://GitHub.com/Naereen/StrapDown.js/graphs/commit-activity)\n[![Code Style](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/ambv/black)\n[![License: MIT](https://img.shields.io/badge/License-MIT-blueviolet.svg)](https://opensource.org/licenses/MIT)\n[![codecov](https://codecov.io/gh/tybruno/assertify/branch/main/graph/badge.svg?token=ZO94EJFI3G)](https://codecov.io/gh/tybruno/assertify)\n# assertify\nassertify -- assert or (ver)ify -- is a Flexible, and Extendable python3.6+ library for evaluating an expression by returning `False` or raising an `AssertionError` or the given `Exception` if the expression is invalid.\n\n#### Key Features:\n* **Easy**: Designed to make it easy to evaluate an expression and return `True`/`False` or raise an `AssertionError` or `Exception`.\n* **Great Developer Experience**: Being fully typed makes it great for editor support.\n* **There is More!!!**:\n    * [unittest_assertions](https://github.com/tybruno/unittest_assertions): Assertify is built on top of the `unittest_assertions`, which is a library that converts the assertions from `unittest` to standalone assertions.\n\n## Installation\n```bash\npip install assertify\n```\n## Example\n raises an appropriate exception by default.\n\n### Exception Example\n`AssertifyIsInstance` will raise a `TypeError` by default, but you can also specify any other type of exception.\n\n```python\nfrom assertifiers.identity import AssertifyIsInstance\n\nis_instance = AssertifyIsInstance()\nis_instance(\"example str\", int)  # raise TypeError(\"'example str' is not an instance of \u003cclass 'int'\u003e\")\n```\n### Assertion Example\nSpecify `AssertionError` to be raised\n\n```python\nfrom assertifiers.identity import AssertifyIsInstance\n\nis_instance = AssertifyIsInstance(raises=AssertionError)\nis_instance(\"example str\", int)  # raise AssertionError(\"'example str' is not an instance of \u003cclass 'int'\u003e\")\n```\n### Boolean Example\nIf `raises=None` assertify will return a `Boolean`.\n\n```python\nfrom assertifiers.identity import AssertifyIsInstance\n\nis_instance = AssertifyIsInstance(raises=None)\nprint(is_instance(\"example str\", int))  # False\n```\n\n### Predicate (Partial Function) Example\n```python\nfrom functools import partial\nfrom assertifiers.identity import AssertifyIsInstances\n\nis_instance = AssertifyIsInstances(must_be_instance_of=any)\npredicate_is_instance = partial(is_instance,classes=[int,float])\nprint(predicate_is_instance(obj=7.62)) # True\n\n```\n\n# Assertifiers\n## Comparison\n| Assertifier | Expression | raises |\n|-----------------|----------------|-----------|\n|AssertifyEqual| assertify `first == second`| ValueError|\n|AssertifyNotEqual| assertify `first != Second` | ValueError|\n|AssertifyAlmostEqual| assertify  `first ~= second`| ValueError|\n|AssertifyNotAlmostEqual| assertify  `first !~= second`| ValueError|\n|AssertifyCountEqual| assertify  `len(first) == len(second)`| ValueError|\n|AssertifyMultilineEqual| assertify  `first.splitlines() == second.splitlines()`| ValueError|\n|AssertifySequenceEqual| assertify  `seq1 == seq2`| ValueError|\n|AssertifyListEqual| assertify  `list1 == list2`| ValueError|\n|AssertifyTupleEqual| assertify  `tuple1 == tuple2`| ValueError|\n|AssertifySetEqual| assertify  `set1 == set2` | ValueError|\n|AssertifyDictEqual| assertify  `dict1 == dict2`| ValueError|\n|AssertifyLess| assertify  `a \u003c b`| ValueError|\n|AssertifyLessEqual| assertify  `a \u003c= b` | ValueError|\n|AssertifyGreater| assertify  `a \u003e b` | ValueError|\n|AssertifyGreater| assertify  `a \u003e= b` | ValueError|\n## Container\n| Assertifier | Expression | raises |\n|-----------------|----------------|-----------|\n|AssertifyIn| assertify  `member in container`| ValueError|\n|AssertifyNotIn| assertify  `member not in container` | ValueError|\n## Control\n| Assertifier | Expression | raises |\n|-----------------|----------------|-----------|\n|AssertifyRaises| assertify  `function raises expected_exception` | ValueError|\n|AssertifyWarns| assertify  `function warns expected_warning` | ValueError|\n|AssertifyLogs| assertify  `logger(level)` | ValueError|\n## Identity\n| Assertifier | Expression | raises |\n|-----------------|----------------|-----------|\n|AssertifyIs| assertify  `exp1 is exp2`| ValueError|\n|AssertifyIsNot| assertify  `exp1 is not exp2`| ValueError|\n|AssertifyIsNone| assertify  `obj is None`| ValueError|\n|AssertifyIsNotNone| assertify  `obj is not None`| ValueError|\n|AssertifyIsInstance| assertify  `isinstance(obj,class)` | TypeError|\n|AssertifyIsInstances| assertify  `isinstance(obj,cls) for cls in classes` | TypeError|\n|AssertifyIsNotInstance| assertify  `not isinstance(obj,class)` | TypeError|\n|AssertifyIsNotInstances| assertify  `not isinstance(obj,cls) for cls in classes` | TypeError|\n## Logic\n| Assertifier | Expression | raises |\n|-----------------|----------------|-----------|\n|AssertifyTrue| assertify  `expr is True`| ValueError|\n|AssertifyFalse| assertify  `expr is False` | ValueError|\n## Regex\n| Assertifier | Expression | raises |\n|-----------------|----------------|-----------|\n|AssertifyRaisesRegex| assertify  `expected_regex in expected_exception_message` | ValueError|\n|AssertifyWarnsRegex| assertify `expected_regex in expected_warning_message` | ValueError|\n|AssertifyRegex| assertify `text in expected_regex`| ValueError|\n|AssertifyNotRegex| assertify `text not in expected_regex`| ValueError| ","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftybruno%2Fassertify","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftybruno%2Fassertify","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftybruno%2Fassertify/lists"}