{"id":13533520,"url":"https://github.com/samuelcolvin/dirty-equals","last_synced_at":"2025-05-13T23:07:25.140Z","repository":{"id":36997180,"uuid":"452345017","full_name":"samuelcolvin/dirty-equals","owner":"samuelcolvin","description":"Doing dirty (but extremely useful) things with equals.","archived":false,"fork":false,"pushed_at":"2025-01-11T23:24:03.000Z","size":1540,"stargazers_count":870,"open_issues_count":17,"forks_count":38,"subscribers_count":12,"default_branch":"main","last_synced_at":"2025-05-12T01:02:04.565Z","etag":null,"topics":["pytest","python","testing-tools","unit-testing"],"latest_commit_sha":null,"homepage":"https://dirty-equals.helpmanual.io","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/samuelcolvin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"samuelcolvin"}},"created_at":"2022-01-26T16:10:05.000Z","updated_at":"2025-05-05T07:17:17.000Z","dependencies_parsed_at":"2024-01-12T23:43:05.531Z","dependency_job_id":"b1ec0257-f6d7-4d8d-9041-c350d7e1d39c","html_url":"https://github.com/samuelcolvin/dirty-equals","commit_stats":{"total_commits":133,"total_committers":18,"mean_commits":7.388888888888889,"dds":"0.18796992481203012","last_synced_commit":"065162ac195964df7f5c47288561809e49deac48"},"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samuelcolvin%2Fdirty-equals","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samuelcolvin%2Fdirty-equals/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samuelcolvin%2Fdirty-equals/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samuelcolvin%2Fdirty-equals/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/samuelcolvin","download_url":"https://codeload.github.com/samuelcolvin/dirty-equals/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253656407,"owners_count":21943081,"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":["pytest","python","testing-tools","unit-testing"],"created_at":"2024-08-01T07:01:20.627Z","updated_at":"2025-05-13T23:07:20.130Z","avatar_url":"https://github.com/samuelcolvin.png","language":"Python","funding_links":["https://github.com/sponsors/samuelcolvin"],"categories":["Python","Assertions","Data Validation"],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://dirty-equals.helpmanual.io\"\u003e\n    \u003cimg src=\"https://dirty-equals.helpmanual.io/latest/img/logo-text.svg\" alt=\"dirty-equals\"\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\u003cp align=\"center\"\u003e\n  \u003cem\u003eDoing dirty (but extremely useful) things with equals.\u003c/em\u003e\n\u003c/p\u003e\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://github.com/samuelcolvin/dirty-equals/actions?query=event%3Apush+branch%3Amain+workflow%3ACI\"\u003e\n    \u003cimg src=\"https://github.com/samuelcolvin/dirty-equals/workflows/CI/badge.svg?event=push\" alt=\"CI\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://codecov.io/gh/samuelcolvin/dirty-equals\"\u003e\n    \u003cimg src=\"https://codecov.io/gh/samuelcolvin/dirty-equals/branch/main/graph/badge.svg\" alt=\"Coverage\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://pypi.python.org/pypi/dirty-equals\"\u003e\n    \u003cimg src=\"https://img.shields.io/pypi/v/dirty-equals.svg\" alt=\"pypi\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/samuelcolvin/dirty-equals\"\u003e\n    \u003cimg src=\"https://img.shields.io/pypi/pyversions/dirty-equals.svg\" alt=\"versions\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/samuelcolvin/dirty-equals/blob/main/LICENSE\"\u003e\n    \u003cimg src=\"https://img.shields.io/github/license/samuelcolvin/dirty-equals.svg\" alt=\"license\"\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n---\n\n**Documentation**: [dirty-equals.helpmanual.io](https://dirty-equals.helpmanual.io)\n\n**Source Code**: [github.com/samuelcolvin/dirty-equals](https://github.com/samuelcolvin/dirty-equals)\n\n---\n\n**dirty-equals** is a python library that (mis)uses the `__eq__` method to make python code (generally unit tests)\nmore declarative and therefore easier to read and write.\n\n*dirty-equals* can be used in whatever context you like, but it comes into its own when writing unit tests for\napplications where you're commonly checking the response to API calls and the contents of a database.\n\n## Usage\n\nHere's a trivial example of what *dirty-equals* can do:\n\n```py\nfrom dirty_equals import IsPositive\n\nassert 1 == IsPositive\nassert -2 == IsPositive  # this will fail!\n```\n\n**That doesn't look very useful yet!**, but consider the following unit test code using *dirty-equals*:\n\n```py title=\"More Powerful Usage\"\nfrom dirty_equals import IsJson, IsNow, IsPositiveInt, IsStr\n\n...\n\n# user_data is a dict returned from a database or API which we want to test\nassert user_data == {\n    # we want to check that id is a positive int\n    'id': IsPositiveInt,\n    # we know avatar_file should be a string, but we need a regex as we don't know whole value\n    'avatar_file': IsStr(regex=r'/[a-z0-9\\-]{10}/example\\.png'),\n    # settings_json is JSON, but it's more robust to compare the value it encodes, not strings\n    'settings_json': IsJson({'theme': 'dark', 'language': 'en'}),\n    # created_ts is datetime, we don't know the exact value, but we know it should be close to now\n    'created_ts': IsNow(delta=3),\n}\n```\n\nWithout *dirty-equals*, you'd have to compare individual fields and/or modify some fields before comparison -\nthe test would not be declarative or as clear.\n\n*dirty-equals* can do so much more than that, for example:\n\n* [`IsPartialDict`](https://dirty-equals.helpmanual.io/types/dict/#dirty_equals.IsPartialDict)\n  lets you compare a subset of a dictionary\n* [`IsStrictDict`](https://dirty-equals.helpmanual.io/types/dict/#dirty_equals.IsStrictDict)\n  lets you confirm order in a dictionary\n* [`IsList`](https://dirty-equals.helpmanual.io/types/sequence/#dirty_equals.IsList) and\n  [`IsTuple`](https://dirty-equals.helpmanual.io/types/sequence/#dirty_equals.IsTuple)\n  lets you compare partial lists and tuples, with or without order constraints\n* nesting any of these types inside any others\n* [`IsInstance`](https://dirty-equals.helpmanual.io/types/other/#dirty_equals.IsInstance)\n  lets you simply confirm the type of an object\n* You can even use [boolean operators](https://dirty-equals.helpmanual.io/usage/#boolean-logic)\n  `|` and `\u0026` to combine multiple conditions\n* and much more...\n\n## Installation\n\nSimply:\n\n```bash\npip install dirty-equals\n```\n\n**dirty-equals** requires **Python 3.8+**.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsamuelcolvin%2Fdirty-equals","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsamuelcolvin%2Fdirty-equals","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsamuelcolvin%2Fdirty-equals/lists"}