{"id":29258156,"url":"https://github.com/tobywf/pytest-iterassert","last_synced_at":"2026-02-23T02:09:18.156Z","repository":{"id":62584099,"uuid":"262249313","full_name":"tobywf/pytest-iterassert","owner":"tobywf","description":"Nicer asserts in pytest for asserting all or any elements or iterables (lists, generators, sets, tuples, strings)","archived":false,"fork":false,"pushed_at":"2020-05-11T06:33:19.000Z","size":15,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-27T03:24:23.184Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tobywf.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":"2020-05-08T06:53:21.000Z","updated_at":"2021-05-21T07:26:00.000Z","dependencies_parsed_at":"2022-11-03T21:48:58.204Z","dependency_job_id":null,"html_url":"https://github.com/tobywf/pytest-iterassert","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/tobywf/pytest-iterassert","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tobywf%2Fpytest-iterassert","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tobywf%2Fpytest-iterassert/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tobywf%2Fpytest-iterassert/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tobywf%2Fpytest-iterassert/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tobywf","download_url":"https://codeload.github.com/tobywf/pytest-iterassert/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tobywf%2Fpytest-iterassert/sbom","scorecard":{"id":891052,"data":{"date":"2025-08-11","repo":{"name":"github.com/tobywf/pytest-iterassert","commit":"98c3dc1821b70c5924918e2d7a6f340309c01187"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.8,"checks":[{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Code-Review","score":0,"reason":"Found 0/3 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/ci.yaml:1","Warn: no topLevel permission defined: .github/workflows/release.yaml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yaml:17: update your workflow using https://app.stepsecurity.io/secureworkflow/tobywf/pytest-iterassert/ci.yaml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yaml:19: update your workflow using https://app.stepsecurity.io/secureworkflow/tobywf/pytest-iterassert/ci.yaml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/ci.yaml:30: update your workflow using https://app.stepsecurity.io/secureworkflow/tobywf/pytest-iterassert/ci.yaml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yaml:11: update your workflow using https://app.stepsecurity.io/secureworkflow/tobywf/pytest-iterassert/release.yaml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yaml:13: update your workflow using https://app.stepsecurity.io/secureworkflow/tobywf/pytest-iterassert/release.yaml/master?enable=pin","Warn: pipCommand not pinned by hash: .github/workflows/ci.yaml:24","Warn: pipCommand not pinned by hash: .github/workflows/ci.yaml:25","Warn: pipCommand not pinned by hash: .github/workflows/release.yaml:18","Warn: pipCommand not pinned by hash: .github/workflows/release.yaml:19","Info:   0 out of   4 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   1 third-party GitHubAction dependencies pinned","Info:   0 out of   4 pipCommand dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: Mozilla Public License 2.0: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":-1,"reason":"internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration","details":null,"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 1 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-24T11:51:01.872Z","repository_id":62584099,"created_at":"2025-08-24T11:51:01.872Z","updated_at":"2025-08-24T11:51:01.872Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29735200,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-22T20:09:16.275Z","status":"online","status_checked_at":"2026-02-23T02:00:06.784Z","response_time":90,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2025-07-04T05:12:04.974Z","updated_at":"2026-02-23T02:09:18.114Z","avatar_url":"https://github.com/tobywf.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![License: MPL 2.0](https://img.shields.io/badge/License-MPL%202.0-brightgreen.svg)](https://opensource.org/licenses/MPL-2.0)\n[![Build](https://github.com/tobywf/pytest-iterassert/workflows/Build/badge.svg?branch=master\u0026event=push)](https://github.com/tobywf/pytest-iterassert/actions)\n[![codecov](https://codecov.io/gh/tobywf/pytest-iterassert/branch/master/graph/badge.svg)](https://codecov.io/gh/tobywf/pytest-iterassert)\n[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\n\n# pytest-iterassert\n\nHave you ever wanted to use `all` or `any` in a unit test, but found the assert\nmessage to be lacking? Do assertions on class attributes in collections almost\nmake you wish you were coding in Java (with a nice assertion framework)? Then\nthis is the [pytest](https://docs.pytest.org/en/latest/) helper for you!\n[pytest-iterassert](https://github.com/tobywf/pytest-iterassert) provides\n`all_match` and `any_match` to give you nice asserts.\n\n## Examples\n\nThe built-in [`any`](https://docs.python.org/3/library/functions.html#any) or\n[`all`](https://docs.python.org/3/library/functions.html#all) can cause a lot of\nsadness when tests fail:\n\n```plain\n    def test_generator_without_iterassert() -\u003e None:\n\u003e       assert all(i \u003c 1 for i in range(3))\nE       assert False\nE        +  where False = all(\u003cgenexpr\u003e at 0x10221a250\u003e)\n```\n\n`all_match` and `any_match` make debugging easy by hoisting the comparison out,\nand printing meaningful debug:\n\n```plain\n    def test_generator_with_iterassert() -\u003e None:\n\u003e       assert all_match(range(3)) \u003c 1\nE       assert all(0, 1, 2) \u003c 1\nE        +  where all(0, 1, 2) = all_match(range(0, 3))\nE        +    where range(0, 3) = range(3)\n```\n\nHow about a more complex example? Asserting attributes of a class instance is\npretty common.\n\n``` plain\n    def test_attr_of_classes_without_iterassert() -\u003e None:\n        foos = [Foo(1), Foo(2), Foo(3)]\n\u003e       assert all(foo.bar \u003c 3 for foo in foos)\nE       assert False\nE        +  where False = all(\u003cgenexpr\u003e at 0x10597ca50\u003e)\n```\n\n`iterassert` makes it easy to apply functions to the iterable, and will convince\npytest to show you the result of that function!\n\n``` plain\n    def test_attr_of_classes_with_iterassert_1() -\u003e None:\n        foos = [Foo(1), Foo(2), Foo(3)]\n\u003e       assert all_match(foos, get_bar) \u003c 3\nE       assert all(9001, 9002, 9003) \u003c 3\nE        +  where all(9001, 9002, 9003) = all_match([\u003cFoo(1)\u003e, \u003cFoo(2)\u003e, \u003cFoo(3)\u003e], get_bar)\n```\n\nIt's also possible to run more complex checks against all items, by doing the\nchecking inside a function:\n\n``` plain\n    def test_attr_of_classes_with_iterassert_2() -\u003e None:\n        foos = [Foo(1), Foo(2), Foo(3)]\n\u003e       assert all_match(foos, check_bar)\nE       assert all(False, False, False)\nE        +  where all(False, False, False) = all_match([\u003cFoo(1)\u003e, \u003cFoo(2)\u003e, \u003cFoo(3)\u003e], check_bar)\n```\n\nNote in this case, much like the buildin functions, `all_match` and `any_match`\ntake no operator or operand.\n\nAnd, if you need to incorporate more transformations, but would like to see the\nintermediary items, `capture` allows for this, too:\n\n``` plain\n    def test_attr_of_classes_with_iterassert_3() -\u003e None:\n        foos = [Foo(1), Foo(2), Foo(3)]\n\u003e       assert all_match(capture(foo.bar for foo in foos), check_val)\nE       assert all(False, False, False)\nE        +  where all(False, False, False) = all_match([9001, 9002, 9003], check_val)\nE        +    where [9001, 9002, 9003] = capture(\u003cgenexpr\u003e at 0x1031220d0\u003e)\n```\n\nEven the test summary says it all:\n\n``` plain\nFAILED example.py::test_generator_without_iterassert - assert False\nFAILED example.py::test_generator_with_iterassert - assert all(0, 1, 2) \u003c 1\nFAILED example.py::test_attr_of_classes_without_iterassert - assert False\nFAILED example.py::test_attr_of_classes_with_iterassert_1 - assert all(9001, 9002, 9003) \u003c 3\nFAILED example.py::test_attr_of_classes_with_iterassert_2 - assert all(False, False, False)\nFAILED example.py::test_attr_of_classes_with_iterassert_3 - assert all(False, False, False)\n```\n\n## Installation\n\n[pytest-iterassert is on\nPyPI](https://pypi.org/project/pytest-iterassert/), so you can simply install\nvia `pip install pytest-iterassert` (requires Python 3.6 or higher).\n\n(If you're really brave, you can also alias `all_match` and `any_match` to the\nbuiltin functions on import.)\n\n## Changelog\n\n### [0.0.3] - 2020-05-10\n\n* Add `capture`, and allow `all_match` and `any_match` to not take an\n  operator/operand, for checks inside the mapping function\n\n### [0.0.2] - 2020-05-07\n\n* Initial release\n\n## Development\n\nThis library uses [Poetry](https://python-poetry.org/) for managing\ndependencies. You just need to run `poetry install`, and it will create a\nvirtual environment with all developer dependencies installed.\n\nPlease run `poetry run ./lint` before submitting pull requests.\n\n## License\n\nThis library is licensed under the Mozilla Public License Version 2.0. For more\ninformation, see `LICENSE`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftobywf%2Fpytest-iterassert","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftobywf%2Fpytest-iterassert","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftobywf%2Fpytest-iterassert/lists"}