>>> list(TestComplexity.make_names(1)) ['a'] >>> list(TestComplexity.make_names(2)) ['a', 'b'] >>> list(TestComplexity.make_names(30)) ['aa', 'ab', ..., 'bd'] >>> list(TestComplexity.make_names(17124)) ['aaa', 'aab', ..., 'zip']
(cls, width, letters=string.ascii_lowercase)
| 40 | |
| 41 | @classmethod |
| 42 | def make_names(cls, width, letters=string.ascii_lowercase): |
| 43 | """ |
| 44 | >>> list(TestComplexity.make_names(1)) |
| 45 | ['a'] |
| 46 | >>> list(TestComplexity.make_names(2)) |
| 47 | ['a', 'b'] |
| 48 | >>> list(TestComplexity.make_names(30)) |
| 49 | ['aa', 'ab', ..., 'bd'] |
| 50 | >>> list(TestComplexity.make_names(17124)) |
| 51 | ['aaa', 'aab', ..., 'zip'] |
| 52 | """ |
| 53 | # determine how many products are needed to produce width |
| 54 | n_products = max(1, math.ceil(math.log(width, len(letters)))) |
| 55 | inputs = (letters,) * n_products |
| 56 | combinations = itertools.product(*inputs) |
| 57 | names = map(''.join, combinations) |
| 58 | return itertools.islice(names, width) |
| 59 | |
| 60 | @classmethod |
| 61 | def make_deep_paths(cls, depth): |
no test coverage detected