pax_global_header00006660000000000000000000000064134655062560014526gustar00rootroot0000000000000052 comment=192622a7bd8164fa21afe8b807102cbceb36db9a allpairspy-2.5.0/000077500000000000000000000000001346550625600137125ustar00rootroot00000000000000allpairspy-2.5.0/.coveragerc000066400000000000000000000003471346550625600160370ustar00rootroot00000000000000[report] # Regexes for lines to exclude from consideration exclude_lines = except ImportError raise NotImplementedError pass ABCmeta abstractmethod abstractproperty abstractclassmethod warnings.warn allpairspy-2.5.0/.gitignore000066400000000000000000000025701346550625600157060ustar00rootroot00000000000000# Byte-compiled / optimized / DLL files __pycache__/ *.py[cod] *$py.class # C extensions *.so # Distribution / packaging .Python build/ develop-eggs/ dist/ downloads/ eggs/ .eggs/ lib/ lib64/ parts/ sdist/ var/ wheels/ pip-wheel-metadata/ share/python-wheels/ *.egg-info/ .installed.cfg *.egg MANIFEST # PyInstaller # Usually these files are written by a python script from a template # before PyInstaller builds the exe, so as to inject date/other infos into it. *.manifest *.spec # Installer logs pip-log.txt pip-delete-this-directory.txt # Unit test / coverage reports htmlcov/ .tox/ .nox/ .coverage .coverage.* .cache nosetests.xml coverage.xml *.cover .hypothesis/ .pytest_cache/ # Translations *.mo *.pot # Django stuff: *.log local_settings.py db.sqlite3 # Flask stuff: instance/ .webassets-cache # Scrapy stuff: .scrapy # Sphinx documentation docs/_build/ # PyBuilder target/ # Jupyter Notebook .ipynb_checkpoints # IPython profile_default/ ipython_config.py # pyenv .python-version # celery beat schedule file celerybeat-schedule # SageMath parsed files *.sage.py # Environments .env .venv env/ venv/ ENV/ env.bak/ venv.bak/ # Spyder project settings .spyderproject .spyproject # Rope project settings .ropeproject # mkdocs documentation /site # mypy .mypy_cache/ .dmypy.json dmypy.json # Pyre type checker .pyre/ # User settings _sandbox/ *_profile Untitled.ipynb allpairspy-2.5.0/.travis.yml000066400000000000000000000031461346550625600160270ustar00rootroot00000000000000language: python cache: pip matrix: include: - os: linux python: 2.7 env: TOXENV=py27 - os: linux python: 3.5 env: TOXENV=py35 - os: linux python: 3.6 env: TOXENV=py36 - os: linux dist: xenial python: 3.7 env: TOXENV=py37 - os: linux dist: xenial python: 3.8-dev env: TOXENV=py38 - os: linux python: 3.6 env: TOXENV=cov after_success: - travis_retry pip install pytest-cov coveralls --upgrade - python setup.py test --addopts "-v --cov allpairspy --cov-report term-missing" - coveralls - os: osx language: generic env: TOXENV=py36 install: - travis_retry bash -x .travis/install.sh script: - bash -x .travis/run_test.sh notifications: slack: secure: buhKHDpBl9aOddo6uC6wZH7qMMwaz/QF7i6VKxxslRPQWdXTVkeWDvacDRyVW6dhXHPMPr+HDeELsqNi3VoQuBWcXWmr+vNry2lGaXqRJCPQ/vW0Nn95RyZ9PogJ+XiO8OwRXujnWqUETynHh3VnOJWskHfcCanZDl4TfSadWQclEZ+r0viXuoBPwzSNkqu/PIHQl9lG47+x1Quh1yq9uQ87JiGIHvZ1I2FxibpSVEW35GBxWfwo0YFH1MZYz6Lpvc9gd7i5knygvjgkvCbwVEhPy9fC+TCo6nMBh7mA9YH0RETtUs9f3vwgZHBrtMaSCsLfWq5s/+Tj7fkcQ0IBQSx9uCeIKl1GSqgK5I3vLwH4icb3txxLVxLcMJNEJxpfcPUUWFb6CYBbRndkakMFEw5uyHwDbN6PBqWqAyMfqbfGOR38bQGQTcz7onw5nNK5gNHGJ3eMRLzrid+c+BTPbrcFrX4KX8rOLnzkyTWsbJrRVfFqqIPQW+XrDLlcOgg8L1xrBBlMlGYkwuOfsgVZck8Iexv6JRpSECABBCcu/AlYx3lwfxqNqKZU+OQ1/sOv+mri7SXajSumoaSiX/0wL7mhnShAu9F6ZqEMry+evkR30ePOKz1nSKzTiQk0nmbKH2WdbZbS/kCJXFCYZTCzUqKPvk15G46vDabTy8WQCLk= allpairspy-2.5.0/.travis/000077500000000000000000000000001346550625600153005ustar00rootroot00000000000000allpairspy-2.5.0/.travis/install.sh000066400000000000000000000004111346550625600172760ustar00rootroot00000000000000#!/usr/bin/env bash if [ "$TRAVIS_OS_NAME" = "osx" ]; then if ! type python3 > /dev/null 2>&1; then # Install Python3 on osx brew upgrade python fi pip3 install setuptools tox --upgrade else pip install setuptools tox --upgrade fi allpairspy-2.5.0/.travis/run_test.sh000066400000000000000000000001011346550625600174670ustar00rootroot00000000000000#!/usr/bin/env bash if [ "$TOXENV" != "cov" ] ; then tox fi allpairspy-2.5.0/CHANGES.txt000066400000000000000000000015321346550625600155240ustar00rootroot00000000000000Version 2.0.1 (April 4, 2009): - Moved examples into their own directory. - 'example2.2.py' re-written to get rid of frivolous usage of decorators (thanks to Tennis Smith for bringing the example's apparent complexity to our attention). - Easier installation through distutils-based setup.py script. - Created AllPairs project on SourceForge.net with home page at http://apps.sourceforge.net/trac/allpairs/. - Submitted the project to the Python Package Index at http://pypi.python.org/pypi. Version 2.0 (December 2007): - Ability to produce n-wise combinations. - Released as open source to MetaCommunications Engineering website (http://engineering.meta-comm.com). Version 1.0 (May 2002): Initial version, widely adopted at MetaCommunications Inc. for multiple testing projects. allpairspy-2.5.0/LICENSE.txt000066400000000000000000000020611346550625600155340ustar00rootroot00000000000000Copyright (c) 2002-2009, MetaCommunications Inc. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. allpairspy-2.5.0/MANIFEST.in000066400000000000000000000002631346550625600154510ustar00rootroot00000000000000include LICENSE include README.rst include setup.cfg include tox.ini recursive-include requirements * recursive-include test * global-exclude __pycache__/* global-exclude *.pyc allpairspy-2.5.0/Makefile000066400000000000000000000016311346550625600153530ustar00rootroot00000000000000PACKAGE := allpairspy BUILD_WORK_DIR := _work DIST_DIR := $(BUILD_WORK_DIR)/$(PACKAGE)/dist .PHONY: build build: @rm -rf $(BUILD_WORK_DIR)/ @mkdir -p $(BUILD_WORK_DIR)/ @cd $(BUILD_WORK_DIR); \ git clone https://github.com/thombashi/$(PACKAGE).git; \ cd $(PACKAGE); \ python setup.py sdist bdist_wheel @twine check $(DIST_DIR)/* ls -lh $(DIST_DIR)/* .PHONY: clean clean: @rm -rf $(PACKAGE)-*.*.*/ \ $(BUILD_WORK_DIR) \ dist/ \ pip-wheel-metadata/ \ .eggs/ \ .pytest_cache/ \ .tox/ \ **/*/__pycache__/ \ *.egg-info/ @python setup.py clean --all @find . -not -path '*/\.*' -type f | grep -E .+\.py\.[a-z0-9]{32,}\.py$ | xargs -r rm .PHONY: fmt fmt: @black $(CURDIR) @autoflake --in-place --recursive --remove-all-unused-imports --exclude "__init__.py" . @isort --apply --recursive .PHONY: release release: @cd $(BUILD_WORK_DIR)/$(PACKAGE); python setup.py release --sign @make clean allpairspy-2.5.0/README.rst000066400000000000000000000245461346550625600154140ustar00rootroot00000000000000.. contents:: **allpairspy** forked from `bayandin/allpairs `__ :backlinks: top :depth: 2 .. image:: https://badge.fury.io/py/allpairspy.svg :target: https://badge.fury.io/py/allpairspy :alt: PyPI package version .. image:: https://img.shields.io/pypi/pyversions/allpairspy.svg :target: https://pypi.org/project/allpairspy :alt: Supported Python versions .. image:: https://img.shields.io/travis/thombashi/allpairspy/master.svg?label=Linux/macOS%20CI :target: https://travis-ci.org/thombashi/allpairspy :alt: Linux/macOS CI status .. image:: https://img.shields.io/appveyor/ci/thombashi/allpairspy/master.svg?label=Windows%20CI :target: https://ci.appveyor.com/project/thombashi/allpairspy :alt: Windows CI status .. image:: https://coveralls.io/repos/github/thombashi/allpairspy/badge.svg?branch=master :target: https://coveralls.io/github/thombashi/allpairspy?branch=master :alt: Test coverage AllPairs test combinations generator ------------------------------------------------ AllPairs is an open source test combinations generator written in Python, developed and maintained by MetaCommunications Engineering. 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. For more info on pairwise testing see http://www.pairwise.org. Features -------- * Produces good enough dataset. * Pythonic, iterator-style enumeration interface. * Allows to filter out "invalid" combinations during search for the next combination. * Goes beyond pairs! If/when required can generate n-wise combinations. Get Started --------------- Basic Usage ================== :Sample Code: .. code:: python 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("{:2d}: {}".format(i, pairs)) :Output: .. code:: PAIRWISE: 0: ['Brand X', '98', 'Internal', 'Salaried', 6] 1: ['Brand Y', 'NT', 'Modem', 'Hourly', 6] 2: ['Brand Y', '2000', 'Internal', 'Part-Time', 10] 3: ['Brand X', 'XP', 'Modem', 'Contr.', 10] 4: ['Brand X', '2000', 'Modem', 'Part-Time', 15] 5: ['Brand Y', 'XP', 'Internal', 'Hourly', 15] 6: ['Brand Y', '98', 'Modem', 'Salaried', 30] 7: ['Brand X', 'NT', 'Internal', 'Contr.', 30] 8: ['Brand X', '98', 'Internal', 'Hourly', 60] 9: ['Brand Y', '2000', 'Modem', 'Contr.', 60] 10: ['Brand Y', 'NT', 'Modem', 'Salaried', 60] 11: ['Brand Y', 'XP', 'Modem', 'Part-Time', 60] 12: ['Brand Y', '2000', 'Modem', 'Hourly', 30] 13: ['Brand Y', '98', 'Modem', 'Contr.', 15] 14: ['Brand Y', 'XP', 'Modem', 'Salaried', 15] 15: ['Brand Y', 'NT', 'Modem', 'Part-Time', 15] 16: ['Brand Y', 'XP', 'Modem', 'Part-Time', 30] 17: ['Brand Y', '98', 'Modem', 'Part-Time', 6] 18: ['Brand Y', '2000', 'Modem', 'Salaried', 6] 19: ['Brand Y', '98', 'Modem', 'Salaried', 10] 20: ['Brand Y', 'XP', 'Modem', 'Contr.', 6] 21: ['Brand Y', 'NT', 'Modem', 'Hourly', 10] Filtering ================== You can restrict pairs by setting filtering function to ``filter_func`` at ``AllPairs`` constructor. :Sample Code: .. code:: python from allpairspy import AllPairs def is_valid_combination(row): """ This is a filtering function. Filtering functions should return True if combination is valid and False otherwise. Test row that is passed here can be incomplete. To prevent search for unnecessary items filtering function is executed with found subset of data to validate it. """ n = len(row) if n > 1: # Brand Y does not support Windows 98 if "98" == row[1] and "Brand Y" == row[0]: return False # Brand X does not work with XP if "XP" == row[1] and "Brand X" == row[0]: return False if n > 4: # Contractors are billed in 30 min increments if "Contr." == row[3] and row[4] < 30: return False return True 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, filter_func=is_valid_combination)): print("{:2d}: {}".format(i, pairs)) :Output: .. code:: PAIRWISE: 0: ['Brand X', '98', 'Internal', 'Salaried', 6] 1: ['Brand Y', 'NT', 'Modem', 'Hourly', 6] 2: ['Brand Y', '2000', 'Internal', 'Part-Time', 10] 3: ['Brand X', '2000', 'Modem', 'Contr.', 30] 4: ['Brand X', 'NT', 'Internal', 'Contr.', 60] 5: ['Brand Y', 'XP', 'Modem', 'Salaried', 60] 6: ['Brand X', '98', 'Modem', 'Part-Time', 15] 7: ['Brand Y', 'XP', 'Internal', 'Hourly', 15] 8: ['Brand Y', 'NT', 'Internal', 'Part-Time', 30] 9: ['Brand X', '2000', 'Modem', 'Hourly', 10] 10: ['Brand Y', 'XP', 'Modem', 'Contr.', 30] 11: ['Brand Y', '2000', 'Modem', 'Salaried', 15] 12: ['Brand Y', 'NT', 'Modem', 'Salaried', 10] 13: ['Brand Y', 'XP', 'Modem', 'Part-Time', 6] 14: ['Brand Y', '2000', 'Modem', 'Contr.', 60] OrderedDict ================== You can use ``collections.OrderedDict`` instance as an argument for ``AllPairs`` constructor. Pairs returned as ``collections.namedtuple`` instances. :Sample Code: .. code:: python from collections import OrderedDict from allpairspy import AllPairs parameters = OrderedDict({ "brand": ["Brand X", "Brand Y"], "os": ["98", "NT", "2000", "XP"], "minute": [15, 30, 60], }) print("PAIRWISE:") for i, pairs in enumerate(AllPairs(parameters)): print("{:2d}: {}".format(i, pairs)) :Sample Code: .. code:: PAIRWISE: 0: Pairs(brand='Brand X', os='98', minute=15) 1: Pairs(brand='Brand Y', os='NT', minute=15) 2: Pairs(brand='Brand Y', os='2000', minute=30) 3: Pairs(brand='Brand X', os='XP', minute=30) 4: Pairs(brand='Brand X', os='2000', minute=60) 5: Pairs(brand='Brand Y', os='XP', minute=60) 6: Pairs(brand='Brand Y', os='98', minute=60) 7: Pairs(brand='Brand X', os='NT', minute=60) 8: Pairs(brand='Brand X', os='NT', minute=30) 9: Pairs(brand='Brand X', os='98', minute=30) 10: Pairs(brand='Brand X', os='XP', minute=15) 11: Pairs(brand='Brand X', os='2000', minute=15) Parameterized testing with pairwise by using py.test ==================================================================== :Sample Code: .. code:: python import pytest from allpairspy import AllPairs def function_to_be_tested(brand, operating_system, minute): # do something return True class TestParameterized(object): @pytest.mark.parametrize(["brand", "operating_system", "minute"], [ value_list for value_list in AllPairs([ ["Brand X", "Brand Y"], ["98", "NT", "2000", "XP"], [10, 15, 30, 60] ]) ]) def test(self, brand, operating_system, minute): assert function_to_be_tested(brand, operating_system, minute) :Output: .. code:: $ py.test test_parameterize.py -v ============================= test session starts ============================== ... collected 16 items test_parameterize.py::TestParameterized::test[Brand X-98-10] PASSED [ 6%] test_parameterize.py::TestParameterized::test[Brand Y-NT-10] PASSED [ 12%] test_parameterize.py::TestParameterized::test[Brand Y-2000-15] PASSED [ 18%] test_parameterize.py::TestParameterized::test[Brand X-XP-15] PASSED [ 25%] test_parameterize.py::TestParameterized::test[Brand X-2000-30] PASSED [ 31%] test_parameterize.py::TestParameterized::test[Brand Y-XP-30] PASSED [ 37%] test_parameterize.py::TestParameterized::test[Brand Y-98-60] PASSED [ 43%] test_parameterize.py::TestParameterized::test[Brand X-NT-60] PASSED [ 50%] test_parameterize.py::TestParameterized::test[Brand X-NT-30] PASSED [ 56%] test_parameterize.py::TestParameterized::test[Brand X-98-30] PASSED [ 62%] test_parameterize.py::TestParameterized::test[Brand X-XP-60] PASSED [ 68%] test_parameterize.py::TestParameterized::test[Brand X-2000-60] PASSED [ 75%] test_parameterize.py::TestParameterized::test[Brand X-2000-10] PASSED [ 81%] test_parameterize.py::TestParameterized::test[Brand X-XP-10] PASSED [ 87%] test_parameterize.py::TestParameterized::test[Brand X-98-15] PASSED [ 93%] test_parameterize.py::TestParameterized::test[Brand X-NT-15] PASSED [100%] Other Examples ================= Other examples could be found in `examples `__ directory. Installation ------------ Install from PyPI ================================== :: pip install allpairspy Install from PPA (for Ubuntu) ================================== :: sudo add-apt-repository ppa:thombashi/ppa sudo apt update sudo apt install python3-allpairspy Known issues ------------ * Not optimal - there are tools that can create smaller set covering all the pairs. However, they are missing some other important features and/or do not integrate well with Python. * Lousy written filtering function may lead to full permutation of parameters. * Version 2.0 has become slower (a side-effect of introducing ability to produce n-wise combinations). Dependencies ------------ Python 2.7+ or 3.5+ - `six `__ allpairspy-2.5.0/allpairspy/000077500000000000000000000000001346550625600160725ustar00rootroot00000000000000allpairspy-2.5.0/allpairspy/__init__.py000066400000000000000000000003051346550625600202010ustar00rootroot00000000000000# encoding: utf-8 from .__version__ import ( __author__, __author_email__, __license__, __maintainer__, __maintainer_email__, __version__, ) from .allpairs import AllPairs allpairspy-2.5.0/allpairspy/__version__.py000066400000000000000000000004021346550625600207210ustar00rootroot00000000000000# encoding: utf-8 __author__ = "MetaCommunications Engineering" __author_email__ = "metacomm@users.sourceforge.net" __maintainer__ = "Tsuyoshi Hombashi" __maintainer_email__ = "tsuyoshi.hombashi@gmail.com" __license__ = "MIT License" __version__ = "2.5.0" allpairspy-2.5.0/allpairspy/allpairs.py000066400000000000000000000171041346550625600202560ustar00rootroot00000000000000# encoding: utf-8 from collections import OrderedDict, namedtuple from functools import cmp_to_key from itertools import combinations import six from six.moves import range, reduce from .pairs_storage import PairsStorage, key class Item(object): @property def id(self): return self.__item_id @property def value(self): return self.__value @property def weights(self): return self.__weights def __init__(self, item_id, value): self.__item_id = item_id self.__value = value self.set_weights([]) def __str__(self): return str(self.__dict__) def set_weights(self, weights): self.__weights = weights def get_max_combination_number(prameter_matrix, n): param_len_list = [len(value_list) for value_list in prameter_matrix] return sum([reduce(lambda x, y: x * y, z) for z in combinations(param_len_list, n)]) def cmp_item(lhs, rhs): if lhs.weights == rhs.weights: return 0 return -1 if lhs.weights < rhs.weights else 1 class AllPairs(object): def __init__(self, parameters, filter_func=lambda x: True, previously_tested=None, n=2): """ TODO: check that input arrays are: - (optional) has no duplicated values inside single array / or compress such values """ if not previously_tested: previously_tested = [[]] self.__validate_parameter(parameters) self.__is_ordered_dict_param = isinstance(parameters, OrderedDict) self.__param_name_list = self.__extract_param_name_list(parameters) self.__pairs_class = namedtuple("Pairs", self.__param_name_list) self.__filter_func = filter_func self.__n = n self.__pairs = PairsStorage(n) value_matrix = self.__extract_value_matrix(parameters) self.__max_unique_pairs_expected = get_max_combination_number(value_matrix, n) self.__working_item_matrix = self.__get_working_item_matrix(value_matrix) for arr in previously_tested: if not arr: continue if len(arr) != len(self.__working_item_matrix): raise RuntimeError("previously tested combination is not complete") if not self.__filter_func(arr): raise ValueError("invalid tested combination is provided") tested = [] for i, val in enumerate(arr): idxs = [ Item(item.id, 0) for item in self.__working_item_matrix[i] if item.value == val ] if len(idxs) != 1: raise ValueError( "value from previously tested combination is not " "found in the parameters or found more than " "once" ) tested.append(idxs[0]) self.__pairs.add_sequence(tested) def __iter__(self): return self def next(self): return self.__next__() def __next__(self): assert len(self.__pairs) <= self.__max_unique_pairs_expected if len(self.__pairs) == self.__max_unique_pairs_expected: # no reasons to search further - all pairs are found raise StopIteration() previous_unique_pairs_count = len(self.__pairs) chosen_item_list = [None] * len(self.__working_item_matrix) indexes = [None] * len(self.__working_item_matrix) direction = 1 i = 0 while -1 < i < len(self.__working_item_matrix): if direction == 1: # move forward self.__resort_working_array(chosen_item_list[:i], i) indexes[i] = 0 elif direction == 0 or direction == -1: # scan current array or go back indexes[i] += 1 if indexes[i] >= len(self.__working_item_matrix[i]): direction = -1 if i == 0: raise StopIteration() i += direction continue direction = 0 else: raise ValueError("next(): unknown 'direction' code '{}'".format(direction)) chosen_item_list[i] = self.__working_item_matrix[i][indexes[i]] if self.__filter_func(self.__get_values(chosen_item_list[: i + 1])): assert direction > -1 direction = 1 else: direction = 0 i += direction if len(self.__working_item_matrix) != len(chosen_item_list): raise StopIteration() self.__pairs.add_sequence(chosen_item_list) if len(self.__pairs) == previous_unique_pairs_count: # could not find new unique pairs - stop raise StopIteration() # replace returned array elements with real values and return it return self.__get_iteration_value(chosen_item_list) def __validate_parameter(self, value): if isinstance(value, OrderedDict): for parameter_list in six.itervalues(value): if not parameter_list: raise ValueError("each parameter arrays must have at least one item") return if len(value) < 2: raise ValueError("must provide more than one option") for parameter_list in value: if not parameter_list: raise ValueError("each parameter arrays must have at least one item") def __resort_working_array(self, chosen_item_list, num): for item in self.__working_item_matrix[num]: data_node = self.__pairs.get_node_info(item) new_combs = [ # numbers of new combinations to be created if this item is # appended to array set([key(z) for z in combinations(chosen_item_list + [item], i + 1)]) - self.__pairs.get_combs()[i] for i in range(0, self.__n) ] # weighting the node node that creates most of new pairs is the best weights = [-len(new_combs[-1])] # less used outbound connections most likely to produce more new # pairs while search continues weights.extend( [len(data_node.out)] + [len(x) for x in reversed(new_combs[:-1])] + [-data_node.counter] # less used node is better ) # otherwise we will prefer node with most of free inbound # connections; somehow it works out better ;) weights.append(-len(data_node.in_)) item.set_weights(weights) self.__working_item_matrix[num].sort(key=cmp_to_key(cmp_item)) def __get_working_item_matrix(self, parameter_matrix): return [ [ Item("a{:d}v{:d}".format(param_idx, value_idx), value) for value_idx, value in enumerate(value_list) ] for param_idx, value_list in enumerate(parameter_matrix) ] @staticmethod def __get_values(item_list): return [item.value for item in item_list] def __get_iteration_value(self, item_list): if not self.__param_name_list: return [item.value for item in item_list] return self.__pairs_class(*[item.value for item in item_list]) def __extract_param_name_list(self, parameters): if not self.__is_ordered_dict_param: return [] return list(parameters) def __extract_value_matrix(self, parameters): if not self.__is_ordered_dict_param: return parameters return [v for v in six.itervalues(parameters)] allpairspy-2.5.0/allpairspy/pairs_storage.py000066400000000000000000000033631346550625600213130ustar00rootroot00000000000000# encoding: utf-8 from itertools import combinations from six.moves import range class Node(object): @property def id(self): return self.__node_id @property def counter(self): return self.__counter def __init__(self, node_id): self.__node_id = node_id self.__counter = 0 self.in_ = set() self.out = set() def __str__(self): return str(self.__dict__) def inc_counter(self): self.__counter += 1 key_cache = {} def key(items): if items in key_cache: return key_cache[items] key_value = tuple([x.id for x in items]) key_cache[items] = key_value return key_value class PairsStorage(object): def __init__(self, n): self.__n = n self.__nodes = {} self.__combs_arr = [set() for _i in range(n)] def __len__(self): return len(self.__combs_arr[-1]) def add_sequence(self, sequence): for i in range(1, self.__n + 1): for combination in combinations(sequence, i): self.__add_combination(combination) def get_node_info(self, item): return self.__nodes.get(item.id, Node(item.id)) def get_combs(self): return self.__combs_arr def __add_combination(self, combination): n = len(combination) assert n > 0 self.__combs_arr[n - 1].add(key(combination)) if n == 1 and combination[0].id not in self.__nodes: self.__nodes[combination[0].id] = Node(combination[0].id) return ids = [x.id for x in combination] for i, id in enumerate(ids): curr = self.__nodes[id] curr.inc_counter() curr.in_.update(ids[:i]) curr.out.update(ids[i + 1 :]) allpairspy-2.5.0/appveyor.yml000066400000000000000000000014641346550625600163070ustar00rootroot00000000000000build: false environment: matrix: - PYTHON: "C:/Python27-x64" - PYTHON: "C:/Python35-x64" - PYTHON: "C:/Python36-x64" - PYTHON: "C:/Python37-x64" init: - "ECHO %PYTHON%" - ps: "ls C:/Python*" install: - ps: "[Net.ServicePointManager]::SecurityProtocol = 'Ssl3, Tls, Tls11, Tls12'" - ps: (new-object net.webclient).DownloadFile('https://bootstrap.pypa.io/get-pip.py', 'C:/get-pip.py') - "%PYTHON%/python.exe C:/get-pip.py" - "%PYTHON%/Scripts/pip.exe --version" - "%PYTHON%/Scripts/pip.exe install .[test]" test_script: - "%PYTHON%/python.exe setup.py test" notifications: - provider: Slack auth_token: secure: JyTQAtBzpPYiWK3eRTz/U+rvmAKopqIWE19ti4vSL/IRygV3jUVUkwET1VyTlrqOeYfNx3Kfcp7eUmHCHxFCgw== channel: notifications allpairspy-2.5.0/examples/000077500000000000000000000000001346550625600155305ustar00rootroot00000000000000allpairspy-2.5.0/examples/compare_to_others.py000077500000000000000000000021161346550625600216210ustar00rootroot00000000000000#!/usr/bin/env python # encoding: utf-8 from __future__ import print_function from allpairspy import AllPairs """ Provided to make it easier to compare efficiency with other tools as per http://pairwise.org/tools.asp Current iuput is: 3^4: produces 9 rows 3^13: produces 17 rows 4^15 * 3^17 * 2^29: produces 37 rows 4^1 * 3^39 * 2^35: produces 27 rows 3^100: produces 29 rows 10^20: produces 219 rows 10^10: produces 172 rows """ def get_arrays(dimensions): opts = [] for d in dimensions: r = [] for _i in range(d[1]): r.append(range(d[0])) opts += r return opts def print_result(dimensions): header_list = [] for d in dimensions: header_list.append("%i^%i" % d) pairwise = AllPairs(get_arrays(dimensions)) n = len(list(pairwise)) print("{:s}: produces {:d} rows".format(" * ".join(header_list), n)) print_result(((3, 4),)) print_result(((3, 13),)) print_result(((4, 15), (3, 17), (2, 29))) print_result(((4, 1), (3, 39), (2, 35))) print_result(((3, 100),)) print_result(((10, 20),)) print_result(((10, 10),)) allpairspy-2.5.0/examples/example1.1.py000077500000000000000000000011271346550625600177610ustar00rootroot00000000000000#!/usr/bin/env python # encoding: utf-8 """ Demo of the basic functionality - just getting pairwise/n-wise combinations """ from __future__ import print_function 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], ] # sample parameters are is taken from # http://www.stsc.hill.af.mil/consulting/sw_testing/improvement/cst.html print("PAIRWISE:") for i, pairs in enumerate(AllPairs(parameters)): print("{:2d}: {}".format(i, pairs)) allpairspy-2.5.0/examples/example1.2.py000077500000000000000000000011361346550625600177620ustar00rootroot00000000000000#!/usr/bin/env python # encoding: utf-8 """ Demo of the basic functionality - just getting pairwise/n-wise combinations """ from __future__ import print_function 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], ] # sample parameters are is taken from # http://www.stsc.hill.af.mil/consulting/sw_testing/improvement/cst.html print("TRIPLEWISE:") for i, pairs in enumerate(AllPairs(parameters, n=3)): print("{:2d}: {}".format(i, pairs)) allpairspy-2.5.0/examples/example1.3.py000077500000000000000000000014561346550625600177700ustar00rootroot00000000000000#!/usr/bin/env python # encoding: utf-8 """ Demo of the basic functionality - just getting pairwise combinations and skipping previously tested pairs. """ from __future__ import print_function 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], ] # sample parameters are is taken from # http://www.stsc.hill.af.mil/consulting/sw_testing/improvement/cst.html tested = [ ["Brand X", "98", "Modem", "Hourly", 10], ["Brand X", "98", "Modem", "Hourly", 15], ["Brand Y", "NT", "Internal", "Part-Time", 10], ] print("PAIRWISE:") for i, pairs in enumerate(AllPairs(parameters, previously_tested=tested)): print("{:2d}: {}".format(i, pairs)) allpairspy-2.5.0/examples/example2.1.py000077500000000000000000000025231346550625600177630ustar00rootroot00000000000000#!/usr/bin/env python # encoding: utf-8 """ Demo of filtering capabilities """ from __future__ import print_function from allpairspy import AllPairs def is_valid_combination(row): """ This is a filtering function. Filtering functions should return True if combination is valid and False otherwise. Test row that is passed here can be incomplete. To prevent search for unnecessary items filtering function is executed with found subset of data to validate it. """ n = len(row) if n > 1: # Brand Y does not support Windows 98 if "98" == row[1] and "Brand Y" == row[0]: return False # Brand X does not work with XP if "XP" == row[1] and "Brand X" == row[0]: return False if n > 4: # Contractors are billed in 30 min increments if "Contr." == row[3] and row[4] < 30: return False return True # sample parameters are is taken from # http://www.stsc.hill.af.mil/consulting/sw_testing/improvement/cst.html 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, filter_func=is_valid_combination)): print("{:2d}: {}".format(i, pairs)) allpairspy-2.5.0/examples/example2.2.py000077500000000000000000000031731346550625600177660ustar00rootroot00000000000000#!/usr/bin/env python # encoding: utf-8 """ Another demo of filtering capabilities. Demonstrates how to use named parameters """ from __future__ import print_function from allpairspy import AllPairs def is_valid_combination(values, names): dictionary = dict(zip(names, values)) """ Should return True if combination is valid and False otherwise. Dictionary that is passed here can be incomplete. To prevent search for unnecessary items filtering function is executed with found subset of data to validate it. """ rules = [ # Brand Y does not support Windows 98 # Brand X does not work with XP # Contractors are billed in 30 min increments lambda d: "98" == d["os"] and "Brand Y" == d["brand"], lambda d: "XP" == d["os"] and "Brand X" == d["brand"], lambda d: "Contr." == d["employee"] and d["increment"] < 30, ] for rule in rules: try: if rule(dictionary): return False except KeyError: pass return True # sample parameters are is taken from # http://www.stsc.hill.af.mil/consulting/sw_testing/improvement/cst.html parameters = [ ("brand", ["Brand X", "Brand Y"]), ("os", ["98", "NT", "2000", "XP"]), ("network", ["Internal", "Modem"]), ("employee", ["Salaried", "Hourly", "Part-Time", "Contr."]), ("increment", [6, 10, 15, 30, 60]), ] pairwise = AllPairs( [x[1] for x in parameters], filter_func=lambda values: is_valid_combination(values, [x[0] for x in parameters]), ) print("PAIRWISE:") for i, pairs in enumerate(pairwise): print("{:2d}: {}".format(i, pairs)) allpairspy-2.5.0/examples/example_ordered_dict.py000066400000000000000000000006001346550625600222400ustar00rootroot00000000000000#!/usr/bin/env python # encoding: utf-8 from __future__ import print_function from collections import OrderedDict from allpairspy import AllPairs parameters = OrderedDict( {"brand": ["Brand X", "Brand Y"], "os": ["98", "NT", "2000", "XP"], "minute": [15, 30, 60]} ) print("PAIRWISE:") for i, pairs in enumerate(AllPairs(parameters)): print("{:2d}: {}".format(i, pairs)) allpairspy-2.5.0/examples/test_parameterize.py000066400000000000000000000013471346550625600216360ustar00rootroot00000000000000#!/usr/bin/env python # encoding: utf-8 """ .. codeauthor:: Tsuyoshi Hombashi """ from __future__ import print_function, unicode_literals import pytest from allpairspy import AllPairs def function_to_be_tested(brand, operating_system, minute): # do something return True class TestParameterized(object): @pytest.mark.parametrize( ["brand", "operating_system", "minute"], [ value_list for value_list in AllPairs( [["Brand X", "Brand Y"], ["98", "NT", "2000", "XP"], [10, 15, 30, 60]] ) ], ) def test(self, brand, operating_system, minute): assert function_to_be_tested(brand, operating_system, minute) allpairspy-2.5.0/pylama.ini000066400000000000000000000005551346550625600157030ustar00rootroot00000000000000[pylama] skip = .eggs/*,.tox/*,*/.env/*,build/*,node_modules/*,_sandbox/*,docs/conf.py [pylama:pycodestyle] max_line_length = 100 # E203: whitespace before ':' (for black) # W503: line break before binary operator (for black) ignore = E203,W503 [pylama:pylint] max_line_length = 100 [pylama:*/__init__.py] # W0611: imported but unused [pyflakes] ignore = W0611 allpairspy-2.5.0/pyproject.toml000066400000000000000000000002221346550625600166220ustar00rootroot00000000000000[tool.black] line-length = 100 exclude = """ .eggs/ | .git/ | .tox/ | .venv/ | _build/ | build/ | dist/ | _sandbox/ | docs/conf.py | setup.py """ allpairspy-2.5.0/requirements/000077500000000000000000000000001346550625600164355ustar00rootroot00000000000000allpairspy-2.5.0/requirements/requirements.txt000066400000000000000000000000231346550625600217140ustar00rootroot00000000000000six>=1.10.0,<2.0.0 allpairspy-2.5.0/requirements/test_requirements.txt000066400000000000000000000000071346550625600227550ustar00rootroot00000000000000pytest allpairspy-2.5.0/setup.cfg000066400000000000000000000000631346550625600155320ustar00rootroot00000000000000[aliases] test=pytest [bdist_wheel] universal = 1 allpairspy-2.5.0/setup.py000077500000000000000000000056241346550625600154360ustar00rootroot00000000000000# encoding: utf-8 import io import os.path import sys import setuptools MODULE_NAME = "allpairspy" REPOSITORY_URL = "https://github.com/thombashi/{:s}".format(MODULE_NAME) REQUIREMENT_DIR = "requirements" pkg_info = {} def need_pytest(): return set(["pytest", "test", "ptr"]).intersection(sys.argv) def get_release_command_class(): try: from releasecmd import ReleaseCommand except ImportError: return {} return {"release": ReleaseCommand} with open(os.path.join(MODULE_NAME, "__version__.py")) as f: exec(f.read(), pkg_info) with io.open("README.rst", encoding="utf8") as fp: long_description = fp.read() with open(os.path.join(REQUIREMENT_DIR, "requirements.txt")) as f: install_requires = [line.strip() for line in f if line.strip()] with open(os.path.join(REQUIREMENT_DIR, "test_requirements.txt")) as f: tests_requires = [line.strip() for line in f if line.strip()] PYTEST_RUNNER_REQUIRES = ["pytest-runner"] if need_pytest() else [] setuptools.setup( name=MODULE_NAME, version=pkg_info["__version__"], url=REPOSITORY_URL, author=pkg_info["__author__"], author_email=pkg_info["__author_email__"], description="Pairwise test combinations generator", long_description=long_description, license=pkg_info["__license__"], maintainer=pkg_info["__maintainer__"], maintainer_email=pkg_info["__maintainer_email__"], packages=setuptools.find_packages(exclude=["test*"]), project_urls={ "Source": REPOSITORY_URL, "Tracker": "{:s}/issues".format(REPOSITORY_URL), }, python_requires=">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*", install_requires=install_requires, setup_requires=PYTEST_RUNNER_REQUIRES, tests_require=tests_requires, extras_require={ "build": ["twine", "wheel"], "release": ["releasecmd>=0.0.18,<0.1.0"], "test": tests_requires, }, classifiers=[ "Development Status :: 5 - Production/Stable", "Environment :: Console", "Intended Audience :: Developers", "Intended Audience :: Information Technology", "Intended Audience :: System Administrators", "License :: OSI Approved :: MIT License", "Natural Language :: English", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Topic :: Software Development :: Libraries", "Topic :: Software Development :: Libraries :: Python Modules", "Topic :: Software Development :: Testing", "Topic :: Utilities", ], cmdclass=get_release_command_class()) allpairspy-2.5.0/test/000077500000000000000000000000001346550625600146715ustar00rootroot00000000000000allpairspy-2.5.0/test/test_allpairs.py000066400000000000000000000244031346550625600201140ustar00rootroot00000000000000# encoding: utf-8 """ .. codeauthor:: Tsuyoshi Hombashi """ from collections import OrderedDict from allpairspy import AllPairs class Test_pairewise_OrderedDict(object): def test_normal(self): parameters = OrderedDict( {"brand": ["Brand X", "Brand Y"], "os": ["NT", "2000", "XP"], "minute": [15, 30, 60]} ) for pairs in AllPairs(parameters): assert pairs.brand == "Brand X" assert pairs.os == "NT" assert pairs.minute == 15 break assert len(list(AllPairs(parameters))) == 9 class Test_pairewise_list(object): # example1.1.py def test_normal(self): parameters = [ ["Brand X", "Brand Y"], ["98", "NT", "2000", "XP"], ["Internal", "Modem"], ["Salaried", "Hourly", "Part-Time", "Contr."], [6, 10, 15, 30, 60], ] assert list(AllPairs(parameters)) == [ ["Brand X", "98", "Internal", "Salaried", 6], ["Brand Y", "NT", "Modem", "Hourly", 6], ["Brand Y", "2000", "Internal", "Part-Time", 10], ["Brand X", "XP", "Modem", "Contr.", 10], ["Brand X", "2000", "Modem", "Part-Time", 15], ["Brand Y", "XP", "Internal", "Hourly", 15], ["Brand Y", "98", "Modem", "Salaried", 30], ["Brand X", "NT", "Internal", "Contr.", 30], ["Brand X", "98", "Internal", "Hourly", 60], ["Brand Y", "2000", "Modem", "Contr.", 60], ["Brand Y", "NT", "Modem", "Salaried", 60], ["Brand Y", "XP", "Modem", "Part-Time", 60], ["Brand Y", "2000", "Modem", "Hourly", 30], ["Brand Y", "98", "Modem", "Contr.", 15], ["Brand Y", "XP", "Modem", "Salaried", 15], ["Brand Y", "NT", "Modem", "Part-Time", 15], ["Brand Y", "XP", "Modem", "Part-Time", 30], ["Brand Y", "98", "Modem", "Part-Time", 6], ["Brand Y", "2000", "Modem", "Salaried", 6], ["Brand Y", "98", "Modem", "Salaried", 10], ["Brand Y", "XP", "Modem", "Contr.", 6], ["Brand Y", "NT", "Modem", "Hourly", 10], ] class Test_triplewise(object): # example1.2.py def test_normal(self): parameters = [ ["Brand X", "Brand Y"], ["98", "NT", "2000", "XP"], ["Internal", "Modem"], ["Salaried", "Hourly", "Part-Time", "Contr."], [6, 10, 15, 30, 60], ] assert list(AllPairs(parameters, n=3)) == [ ["Brand X", "98", "Internal", "Salaried", 6], ["Brand Y", "NT", "Modem", "Hourly", 6], ["Brand Y", "2000", "Modem", "Part-Time", 10], ["Brand X", "XP", "Internal", "Contr.", 10], ["Brand X", "XP", "Modem", "Part-Time", 6], ["Brand Y", "2000", "Internal", "Hourly", 15], ["Brand Y", "NT", "Internal", "Salaried", 10], ["Brand X", "98", "Modem", "Contr.", 15], ["Brand X", "98", "Modem", "Hourly", 10], ["Brand Y", "NT", "Modem", "Contr.", 30], ["Brand X", "XP", "Internal", "Hourly", 30], ["Brand X", "2000", "Modem", "Salaried", 30], ["Brand Y", "2000", "Internal", "Contr.", 6], ["Brand Y", "NT", "Internal", "Part-Time", 60], ["Brand Y", "XP", "Modem", "Salaried", 15], ["Brand X", "98", "Modem", "Part-Time", 60], ["Brand X", "XP", "Modem", "Salaried", 60], ["Brand X", "2000", "Internal", "Part-Time", 15], ["Brand X", "2000", "Modem", "Contr.", 60], ["Brand X", "98", "Modem", "Salaried", 10], ["Brand X", "98", "Modem", "Part-Time", 30], ["Brand X", "NT", "Modem", "Part-Time", 10], ["Brand Y", "NT", "Modem", "Salaried", 60], ["Brand Y", "NT", "Modem", "Hourly", 15], ["Brand Y", "NT", "Modem", "Hourly", 30], ["Brand Y", "NT", "Modem", "Hourly", 60], ["Brand Y", "NT", "Modem", "Hourly", 10], ] class Test_pairewise_w_tested(object): # example1.3.py def test_normal(self): parameters = [ ["Brand X", "Brand Y"], ["98", "NT", "2000", "XP"], ["Internal", "Modem"], ["Salaried", "Hourly", "Part-Time", "Contr."], [6, 10, 15, 30, 60], ] tested = [ ["Brand X", "98", "Modem", "Hourly", 10], ["Brand X", "98", "Modem", "Hourly", 15], ["Brand Y", "NT", "Internal", "Part-Time", 10], ] assert list(AllPairs(parameters, previously_tested=tested)) == [ ["Brand Y", "2000", "Modem", "Salaried", 6], ["Brand X", "XP", "Internal", "Contr.", 6], ["Brand Y", "XP", "Modem", "Contr.", 30], ["Brand X", "2000", "Internal", "Part-Time", 30], ["Brand Y", "98", "Internal", "Salaried", 60], ["Brand X", "NT", "Modem", "Salaried", 60], ["Brand Y", "XP", "Internal", "Hourly", 15], ["Brand Y", "NT", "Modem", "Hourly", 30], ["Brand Y", "2000", "Modem", "Part-Time", 15], ["Brand Y", "2000", "Modem", "Contr.", 10], ["Brand Y", "XP", "Modem", "Salaried", 10], ["Brand Y", "98", "Modem", "Part-Time", 6], ["Brand Y", "NT", "Modem", "Contr.", 15], ["Brand Y", "98", "Modem", "Contr.", 30], ["Brand Y", "XP", "Modem", "Part-Time", 60], ["Brand Y", "2000", "Modem", "Hourly", 60], ["Brand Y", "NT", "Modem", "Salaried", 30], ["Brand Y", "NT", "Modem", "Salaried", 15], ["Brand Y", "NT", "Modem", "Hourly", 6], ["Brand Y", "NT", "Modem", "Contr.", 60], ] class Test_pairewise_filter(object): def test_normal_example21(self): # example2.1.py parameters = [ ["Brand X", "Brand Y"], ["98", "NT", "2000", "XP"], ["Internal", "Modem"], ["Salaried", "Hourly", "Part-Time", "Contr."], [6, 10, 15, 30, 60], ] def is_valid_combination(row): """ Should return True if combination is valid and False otherwise. Test row that is passed here can be incomplete. To prevent search for unnecessary items filtering function is executed with found subset of data to validate it. """ n = len(row) if n > 1: # Brand Y does not support Windows 98 if "98" == row[1] and "Brand Y" == row[0]: return False # Brand X does not work with XP if "XP" == row[1] and "Brand X" == row[0]: return False if n > 4: # Contractors are billed in 30 min increments if "Contr." == row[3] and row[4] < 30: return False return True assert list(AllPairs(parameters, filter_func=is_valid_combination)) == [ ["Brand X", "98", "Internal", "Salaried", 6], ["Brand Y", "NT", "Modem", "Hourly", 6], ["Brand Y", "2000", "Internal", "Part-Time", 10], ["Brand X", "2000", "Modem", "Contr.", 30], ["Brand X", "NT", "Internal", "Contr.", 60], ["Brand Y", "XP", "Modem", "Salaried", 60], ["Brand X", "98", "Modem", "Part-Time", 15], ["Brand Y", "XP", "Internal", "Hourly", 15], ["Brand Y", "NT", "Internal", "Part-Time", 30], ["Brand X", "2000", "Modem", "Hourly", 10], ["Brand Y", "XP", "Modem", "Contr.", 30], ["Brand Y", "2000", "Modem", "Salaried", 15], ["Brand Y", "NT", "Modem", "Salaried", 10], ["Brand Y", "XP", "Modem", "Part-Time", 6], ["Brand Y", "2000", "Modem", "Contr.", 60], ] def test_normal_example22(self): # example2.2.py parameters = [ ("brand", ["Brand X", "Brand Y"]), ("os", ["98", "NT", "2000", "XP"]), ("network", ["Internal", "Modem"]), ("employee", ["Salaried", "Hourly", "Part-Time", "Contr."]), ("increment", [6, 10, 15, 30, 60]), ] def is_valid_combination(values, names): dictionary = dict(zip(names, values)) """ Should return True if combination is valid and False otherwise. Dictionary that is passed here can be incomplete. To prevent search for unnecessary items filtering function is executed with found subset of data to validate it. """ rules = [ # Brand Y does not support Windows 98 # Brand X does not work with XP # Contractors are billed in 30 min increments lambda d: "98" == d["os"] and "Brand Y" == d["brand"], lambda d: "XP" == d["os"] and "Brand X" == d["brand"], lambda d: "Contr." == d["employee"] and d["increment"] < 30, ] for rule in rules: try: if rule(dictionary): return False except KeyError: pass return True assert list( AllPairs( [x[1] for x in parameters], filter_func=lambda values: is_valid_combination(values, [x[0] for x in parameters]), ) ) == [ ["Brand X", "98", "Internal", "Salaried", 6], ["Brand Y", "NT", "Modem", "Hourly", 6], ["Brand Y", "2000", "Internal", "Part-Time", 10], ["Brand X", "2000", "Modem", "Contr.", 30], ["Brand X", "NT", "Internal", "Contr.", 60], ["Brand Y", "XP", "Modem", "Salaried", 60], ["Brand X", "98", "Modem", "Part-Time", 15], ["Brand Y", "XP", "Internal", "Hourly", 15], ["Brand Y", "NT", "Internal", "Part-Time", 30], ["Brand X", "2000", "Modem", "Hourly", 10], ["Brand Y", "XP", "Modem", "Contr.", 30], ["Brand Y", "2000", "Modem", "Salaried", 15], ["Brand Y", "NT", "Modem", "Salaried", 10], ["Brand Y", "XP", "Modem", "Part-Time", 6], ["Brand Y", "2000", "Modem", "Contr.", 60], ] allpairspy-2.5.0/tox.ini000066400000000000000000000001501346550625600152210ustar00rootroot00000000000000[tox] envlist = py{27,35,36,37,38},cov [testenv] deps = pytest commands = python setup.py test