{"id":13625765,"url":"https://github.com/thombashi/allpairspy","last_synced_at":"2025-04-12T17:42:16.072Z","repository":{"id":45490470,"uuid":"79609775","full_name":"thombashi/allpairspy","owner":"thombashi","description":"A python library for test combinations generator. The generator allows one to create a set of tests using \"pairwise combinations\" method, reducing a number of combinations of variables into a lesser set that covers most situations.","archived":false,"fork":false,"pushed_at":"2023-11-01T08:19:45.000Z","size":141,"stargazers_count":276,"open_issues_count":4,"forks_count":44,"subscribers_count":16,"default_branch":"master","last_synced_at":"2025-04-11T08:42:13.761Z","etag":null,"topics":["allpairs","pairwise","python-library","testing"],"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/thombashi.png","metadata":{"files":{"readme":"README.rst","changelog":"CHANGES.txt","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null},"funding":{"github":"thombashi","patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2017-01-20T23:35:40.000Z","updated_at":"2025-02-26T03:52:42.000Z","dependencies_parsed_at":"2023-12-15T02:17:52.945Z","dependency_job_id":"3753a05a-3b6a-43c5-bde5-b04b96380660","html_url":"https://github.com/thombashi/allpairspy","commit_stats":{"total_commits":237,"total_committers":6,"mean_commits":39.5,"dds":"0.27004219409282704","last_synced_commit":"415a2d2c17196e3ace30f4eced8d3bf69b093c7e"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thombashi%2Fallpairspy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thombashi%2Fallpairspy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thombashi%2Fallpairspy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thombashi%2Fallpairspy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thombashi","download_url":"https://codeload.github.com/thombashi/allpairspy/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248608244,"owners_count":21132688,"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":["allpairs","pairwise","python-library","testing"],"created_at":"2024-08-01T21:02:01.348Z","updated_at":"2025-04-12T17:42:16.040Z","avatar_url":"https://github.com/thombashi.png","language":"Python","funding_links":["https://github.com/sponsors/thombashi"],"categories":["Python"],"sub_categories":[],"readme":".. contents:: **allpairspy** forked from `bayandin/allpairs \u003chttps://github.com/bayandin/allpairs\u003e`__\n   :backlinks: top\n   :depth: 2\n\n.. image:: https://badge.fury.io/py/allpairspy.svg\n    :target: https://badge.fury.io/py/allpairspy\n    :alt: PyPI package version\n\n.. image:: https://img.shields.io/pypi/pyversions/allpairspy.svg\n    :target: https://pypi.org/project/allpairspy\n    :alt: Supported Python versions\n\n.. image:: https://github.com/thombashi/allpairspy/workflows/Tests/badge.svg\n    :target: https://github.com/thombashi/allpairspy/actions?query=workflow%3ATests\n    :alt: Linux/macOS/Windows CI status\n\n.. image:: https://coveralls.io/repos/github/thombashi/allpairspy/badge.svg?branch=master\n    :target: https://coveralls.io/github/thombashi/allpairspy?branch=master\n    :alt: Test coverage\n\n\nAllPairs test combinations generator\n------------------------------------------------\nAllPairs is an open source test combinations generator written in\nPython, developed and maintained by MetaCommunications Engineering.\nThe generator allows one to create a set of tests using \"pairwise\ncombinations\" method, reducing a number of combinations of variables\ninto a lesser set that covers most situations.\n\nFor more info on pairwise testing see http://www.pairwise.org.\n\n\nFeatures\n--------\n* Produces good enough dataset.\n* Pythonic, iterator-style enumeration interface.\n* Allows to filter out \"invalid\" combinations during search for the next combination.\n* Goes beyond pairs! If/when required can generate n-wise combinations.\n\n\nGet Started\n---------------\n\nBasic Usage\n==================\n:Sample Code:\n    .. code:: python\n\n        from allpairspy import AllPairs\n\n        parameters = [\n            [\"Brand X\", \"Brand Y\"],\n            [\"98\", \"NT\", \"2000\", \"XP\"],\n            [\"Internal\", \"Modem\"],\n            [\"Salaried\", \"Hourly\", \"Part-Time\", \"Contr.\"],\n            [6, 10, 15, 30, 60],\n        ]\n\n        print(\"PAIRWISE:\")\n        for i, pairs in enumerate(AllPairs(parameters)):\n            print(\"{:2d}: {}\".format(i, pairs))\n\n:Output:\n    .. code::\n\n        PAIRWISE:\n         0: ['Brand X', '98', 'Internal', 'Salaried', 6]\n         1: ['Brand Y', 'NT', 'Modem', 'Hourly', 6]\n         2: ['Brand Y', '2000', 'Internal', 'Part-Time', 10]\n         3: ['Brand X', 'XP', 'Modem', 'Contr.', 10]\n         4: ['Brand X', '2000', 'Modem', 'Part-Time', 15]\n         5: ['Brand Y', 'XP', 'Internal', 'Hourly', 15]\n         6: ['Brand Y', '98', 'Modem', 'Salaried', 30]\n         7: ['Brand X', 'NT', 'Internal', 'Contr.', 30]\n         8: ['Brand X', '98', 'Internal', 'Hourly', 60]\n         9: ['Brand Y', '2000', 'Modem', 'Contr.', 60]\n        10: ['Brand Y', 'NT', 'Modem', 'Salaried', 60]\n        11: ['Brand Y', 'XP', 'Modem', 'Part-Time', 60]\n        12: ['Brand Y', '2000', 'Modem', 'Hourly', 30]\n        13: ['Brand Y', '98', 'Modem', 'Contr.', 15]\n        14: ['Brand Y', 'XP', 'Modem', 'Salaried', 15]\n        15: ['Brand Y', 'NT', 'Modem', 'Part-Time', 15]\n        16: ['Brand Y', 'XP', 'Modem', 'Part-Time', 30]\n        17: ['Brand Y', '98', 'Modem', 'Part-Time', 6]\n        18: ['Brand Y', '2000', 'Modem', 'Salaried', 6]\n        19: ['Brand Y', '98', 'Modem', 'Salaried', 10]\n        20: ['Brand Y', 'XP', 'Modem', 'Contr.', 6]\n        21: ['Brand Y', 'NT', 'Modem', 'Hourly', 10]\n\n\nFiltering\n==================\nYou can restrict pairs by setting a filtering function to ``filter_func`` at\n``AllPairs`` constructor.\n\n:Sample Code:\n    .. code:: python\n\n        from allpairspy import AllPairs\n\n        def is_valid_combination(row):\n            \"\"\"\n            This is a filtering function. Filtering functions should return True\n            if combination is valid and False otherwise.\n\n            Test row that is passed here can be incomplete.\n            To prevent search for unnecessary items filtering function\n            is executed with found subset of data to validate it.\n            \"\"\"\n\n            n = len(row)\n\n            if n \u003e 1:\n                # Brand Y does not support Windows 98\n                if \"98\" == row[1] and \"Brand Y\" == row[0]:\n                    return False\n\n                # Brand X does not work with XP\n                if \"XP\" == row[1] and \"Brand X\" == row[0]:\n                    return False\n\n            if n \u003e 4:\n                # Contractors are billed in 30 min increments\n                if \"Contr.\" == row[3] and row[4] \u003c 30:\n                    return False\n\n            return True\n\n        parameters = [\n            [\"Brand X\", \"Brand Y\"],\n            [\"98\", \"NT\", \"2000\", \"XP\"],\n            [\"Internal\", \"Modem\"],\n            [\"Salaried\", \"Hourly\", \"Part-Time\", \"Contr.\"],\n            [6, 10, 15, 30, 60]\n        ]\n\n        print(\"PAIRWISE:\")\n        for i, pairs in enumerate(AllPairs(parameters, filter_func=is_valid_combination)):\n            print(\"{:2d}: {}\".format(i, pairs))\n\n:Output:\n    .. code::\n\n        PAIRWISE:\n         0: ['Brand X', '98', 'Internal', 'Salaried', 6]\n         1: ['Brand Y', 'NT', 'Modem', 'Hourly', 6]\n         2: ['Brand Y', '2000', 'Internal', 'Part-Time', 10]\n         3: ['Brand X', '2000', 'Modem', 'Contr.', 30]\n         4: ['Brand X', 'NT', 'Internal', 'Contr.', 60]\n         5: ['Brand Y', 'XP', 'Modem', 'Salaried', 60]\n         6: ['Brand X', '98', 'Modem', 'Part-Time', 15]\n         7: ['Brand Y', 'XP', 'Internal', 'Hourly', 15]\n         8: ['Brand Y', 'NT', 'Internal', 'Part-Time', 30]\n         9: ['Brand X', '2000', 'Modem', 'Hourly', 10]\n        10: ['Brand Y', 'XP', 'Modem', 'Contr.', 30]\n        11: ['Brand Y', '2000', 'Modem', 'Salaried', 15]\n        12: ['Brand Y', 'NT', 'Modem', 'Salaried', 10]\n        13: ['Brand Y', 'XP', 'Modem', 'Part-Time', 6]\n        14: ['Brand Y', '2000', 'Modem', 'Contr.', 60]\n\n\nData Source: OrderedDict\n====================================\nYou can use ``collections.OrderedDict`` instance as an argument for ``AllPairs`` constructor.\nPairs will be returned as ``collections.namedtuple`` instances.\n\n:Sample Code:\n    .. code:: python\n\n        from collections import OrderedDict\n        from allpairspy import AllPairs\n\n        parameters = OrderedDict({\n            \"brand\": [\"Brand X\", \"Brand Y\"],\n            \"os\": [\"98\", \"NT\", \"2000\", \"XP\"],\n            \"minute\": [15, 30, 60],\n        })\n\n        print(\"PAIRWISE:\")\n        for i, pairs in enumerate(AllPairs(parameters)):\n            print(\"{:2d}: {}\".format(i, pairs))\n\n:Sample Code:\n    .. code::\n\n        PAIRWISE:\n         0: Pairs(brand='Brand X', os='98', minute=15)\n         1: Pairs(brand='Brand Y', os='NT', minute=15)\n         2: Pairs(brand='Brand Y', os='2000', minute=30)\n         3: Pairs(brand='Brand X', os='XP', minute=30)\n         4: Pairs(brand='Brand X', os='2000', minute=60)\n         5: Pairs(brand='Brand Y', os='XP', minute=60)\n         6: Pairs(brand='Brand Y', os='98', minute=60)\n         7: Pairs(brand='Brand X', os='NT', minute=60)\n         8: Pairs(brand='Brand X', os='NT', minute=30)\n         9: Pairs(brand='Brand X', os='98', minute=30)\n        10: Pairs(brand='Brand X', os='XP', minute=15)\n        11: Pairs(brand='Brand X', os='2000', minute=15)\n\n\nParameterized testing pairwise by using pytest\n====================================================================\n\nParameterized testing: value matrix\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n:Sample Code:\n    .. code:: python\n\n        import pytest\n        from allpairspy import AllPairs\n\n        def function_to_be_tested(brand, operating_system, minute) -\u003e bool:\n            # do something\n            return True\n\n        class TestParameterized(object):\n            @pytest.mark.parametrize([\"brand\", \"operating_system\", \"minute\"], [\n                values for values in AllPairs([\n                    [\"Brand X\", \"Brand Y\"],\n                    [\"98\", \"NT\", \"2000\", \"XP\"],\n                    [10, 15, 30, 60]\n                ])\n            ])\n            def test(self, brand, operating_system, minute):\n                assert function_to_be_tested(brand, operating_system, minute)\n\n:Output:\n    .. code::\n\n        $ py.test test_parameterize.py -v\n        ============================= test session starts ==============================\n        ...\n        collected 16 items\n\n        test_parameterize.py::TestParameterized::test[Brand X-98-10] PASSED      [  6%]\n        test_parameterize.py::TestParameterized::test[Brand Y-NT-10] PASSED      [ 12%]\n        test_parameterize.py::TestParameterized::test[Brand Y-2000-15] PASSED    [ 18%]\n        test_parameterize.py::TestParameterized::test[Brand X-XP-15] PASSED      [ 25%]\n        test_parameterize.py::TestParameterized::test[Brand X-2000-30] PASSED    [ 31%]\n        test_parameterize.py::TestParameterized::test[Brand Y-XP-30] PASSED      [ 37%]\n        test_parameterize.py::TestParameterized::test[Brand Y-98-60] PASSED      [ 43%]\n        test_parameterize.py::TestParameterized::test[Brand X-NT-60] PASSED      [ 50%]\n        test_parameterize.py::TestParameterized::test[Brand X-NT-30] PASSED      [ 56%]\n        test_parameterize.py::TestParameterized::test[Brand X-98-30] PASSED      [ 62%]\n        test_parameterize.py::TestParameterized::test[Brand X-XP-60] PASSED      [ 68%]\n        test_parameterize.py::TestParameterized::test[Brand X-2000-60] PASSED    [ 75%]\n        test_parameterize.py::TestParameterized::test[Brand X-2000-10] PASSED    [ 81%]\n        test_parameterize.py::TestParameterized::test[Brand X-XP-10] PASSED      [ 87%]\n        test_parameterize.py::TestParameterized::test[Brand X-98-15] PASSED      [ 93%]\n        test_parameterize.py::TestParameterized::test[Brand X-NT-15] PASSED      [100%]\n\nParameterized testing: OrderedDict\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n:Sample Code:\n    .. code:: python\n\n        import pytest\n        from allpairspy import AllPairs\n\n        def function_to_be_tested(brand, operating_system, minute) -\u003e bool:\n            # do something\n            return True\n\n        class TestParameterized(object):\n            @pytest.mark.parametrize(\n                [\"pair\"],\n                [\n                    [pair]\n                    for pair in AllPairs(\n                        OrderedDict(\n                            {\n                                \"brand\": [\"Brand X\", \"Brand Y\"],\n                                \"operating_system\": [\"98\", \"NT\", \"2000\", \"XP\"],\n                                \"minute\": [10, 15, 30, 60],\n                            }\n                        )\n                    )\n                ],\n            )\n            def test(self, pair):\n                assert function_to_be_tested(pair.brand, pair.operating_system, pair.minute)\n\n\nOther Examples\n=================\nOther examples could be found in `examples \u003chttps://github.com/thombashi/allpairspy/tree/master/examples\u003e`__ directory.\n\n\nInstallation\n------------\n\nInstallation: pip\n==================================\n::\n\n    pip install allpairspy\n\nInstallation: apt\n==================================\nYou can install the package by ``apt`` via a Personal Package Archive (`PPA \u003chttps://launchpad.net/~thombashi/+archive/ubuntu/ppa\u003e`__):\n\n::\n\n    sudo add-apt-repository ppa:thombashi/ppa\n    sudo apt update\n    sudo apt install python3-allpairspy\n\n\nKnown issues\n------------\n* Not optimal - there are tools that can create smaller set covering\n  all the pairs. However, they are missing some other important\n  features and/or do not integrate well with Python.\n\n* Lousy written filtering function may lead to full permutation of parameters.\n\n* Version 2.0 has become slower (a side-effect of introducing ability to produce n-wise combinations).\n\n\nDependencies\n------------\nPython 3.7+\nno external dependencies.\n\n\nSponsors\n------------\n.. image:: https://avatars.githubusercontent.com/u/3658062?s=48\u0026v=4\n   :target: https://github.com/b4tman\n   :alt: Dmitry Belyaev (b4tman)\n.. image:: https://avatars.githubusercontent.com/u/44389260?s=48\u0026u=6da7176e51ae2654bcfd22564772ef8a3bb22318\u0026v=4\n   :target: https://github.com/chasbecker\n   :alt: Charles Becker (chasbecker)\n.. image:: https://avatars.githubusercontent.com/u/46711571?s=48\u0026u=57687c0e02d5d6e8eeaf9177f7b7af4c9f275eb5\u0026v=4\n   :target: https://github.com/Arturi0\n   :alt: Arturi0\n\n`Become a sponsor \u003chttps://github.com/sponsors/thombashi\u003e`__\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthombashi%2Fallpairspy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthombashi%2Fallpairspy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthombashi%2Fallpairspy/lists"}