Package: covertable
RequirementsPython: 3.3 or later.Tested with 3.7, 3.11Installation$pipinstallcovertableUsageJust importcovertableand callmakefunction.>>>fromcovertableimportmake,sorters,criteria>>>machine_list=['iphone','pixel']>>>os_list=['ios','android']>>>browser_list=['FireFox','Chrome','Safari']>>># list input and output>>>make(...[machine_list,os_list,browser_list],# list factors...length=2,# default: 2...sorter=sorters.random,# default: sorters.hash...criterion=criteria.simple,# default: criteria.greedy...seed=100,# default: ''...pre_filter=lambdarow:not(row[1]=='android'androw[0]!='pixel')andnot(row[1]=='ios'androw[0]!='iphone'),# default: None...)[['pixel','android','Safari'],['iphone','ios','Chrome'],['iphone','ios','Safari'],['pixel','android','Chrome'],['pixel','android','FireFox'],['iphone','ios','FireFox']]>>># dict input and output>>>make(...{'machine':machine_list,'os':os_list,'browser':browser_list},# dict factors...length=2,# default: 2...tolerance=3,# default: 0...post_filter=lambdarow:not(row['os']=='android'androw['machine']!='pixel')andnot(row['os']=='ios'androw['machine']!='iphone'),# default: None...)[{'machine':'pixel','browser':'Chrome','os':'android'},{'machine':'pixel','browser':'FireFox','os':'android'},{'machine':'iphone','os':'ios','browser':'Chrome'},{'os':'ios','browser':'FireFox','machine':'iphone'}]Optionscovertable.makefunction has options as keyword argument.All options are omittable.lengthNumber of factors to be covered. (default: 2)Obviously the more it increases, the more number of combinations increases.sorterCombinations depend on the order of spreading all over the rows.You can choice a sorter from the following:sorters.random:This makes different combinations everytime. (fastest)sorters.hash:This makes combinations depending on hash of the pair and seed. (default)It receivesseedanduseCacheoptions.seedoption decides the order of storing from unstored pairs, therefore it outputs the same result every time when number of factors and seed are the same.useCacheoption decide if using cache of hash or not. (default:true)It is around 10% faster than settinguseCacheoff.criterioncriteria.simple:This extracts any pairs that can be stored into the processing row.criteria.greedy:This attempts to make most efficient combinations. (default)These combinations are not always shorter thansimplecriterion.It receivestoleranceoption.NoteNot relevant options will be ignored.pre_filterThis means a function to filter beforehand.It receives an argumentrowasobjecttype.When the function returnsFalse, the row combination will not be registered.If factors type isArray, you should specify an index at the subscript likerow => row[1] < 6.If factors type isObject, you should specify a key at the subscript likerow =>row['month']< 6post_filterThis means a function to filter later.The usage is the same aspreFilter, only the difference is the timing of the call.
It will delete rows not matched this function at the last.For this reason, the final test cases may not satisfy the factors coverage.Development# preparation$python3-mvenvvenv$sourcevenv/bin/activate(venv)$pipinstall-rdev_requirements.txt# testing(venv)$pytestPublish(venv)$pythonsetup.pysdistbdist_wheel(venv)$twineupload--repositorypypidist/*More infowalkframe/covertable - GitHub