allpairspy: Pairwise Test Combinations Generator
allpairspy is an open-source Python library for generating pairwise (all-pairs) test combinations. It helps reduce the number of test cases while ensuring comprehensive coverage by covering all possible pairs of input parameter values. The library is actively maintained with steady, though infrequent, releases.
Common errors
-
ModuleNotFoundError: No module named 'allpairspy'
cause The allpairspy library is not installed in the current Python environment.fixInstall the library using pip: `pip install allpairspy`. -
TypeError: AllPairs() takes 1 positional argument but 2 were given
cause The constructor expects a single iterable (e.g., a list of lists) containing all parameter sets, not multiple separate arguments.fixWrap your parameter sets in a single list: `AllPairs([["A", "B"], [1, 2]])` instead of `AllPairs(["A", "B"], [1, 2])`. -
ValueError: Parameters list must not be empty
cause The list of parameters provided to `AllPairs` is empty or contains empty sub-lists, which prevents combination generation.fixEnsure the `parameters` list contains at least one non-empty list of values for each factor.
Warnings
- breaking Version 2.5.1 dropped support for Python 2.7, 3.5, and 3.6. Ensure your Python environment is 3.7 or newer.
- breaking Version 2.5.0 dropped support for Python 3.4.
- gotcha Support for `OrderedDict` as a data source was added in version 2.3.0. If you need to use `OrderedDict`, ensure you are on this version or newer.
Install
-
pip install allpairspy
Imports
- AllPairs
from allpairspy import AllPairs
Quickstart
from allpairspy import AllPairs
parameters = [
["Brand X", "Brand Y"],
["98", "NT", "2000", "XP"],
["Internal", "Modem"],
["Salaried", "Hourly", "Part-Time", "Contr."],
[6, 10, 15, 30, 60],
]
print("PAIRWISE:")
for i, pairs in enumerate(AllPairs(parameters)):
print(f"{i:2d}: {pairs}")