Describe list with the given number of elements, each matching corresponding spec :param (Spec,) specs: List of specifications. Last element(s) in this list may be optional. Each element in this list describes element with the same index in the checked value. Check out :py:meth:`Spec.c
(self, *specs)
| 508 | return self |
| 509 | |
| 510 | def tuple(self, *specs): |
| 511 | '''Describe list with the given number of elements, each matching corresponding spec |
| 512 | |
| 513 | :param (Spec,) specs: |
| 514 | List of specifications. Last element(s) in this list may be |
| 515 | optional. Each element in this list describes element with the same |
| 516 | index in the checked value. Check out :py:meth:`Spec.check_tuple` |
| 517 | for more details, but note that there list of specifications is |
| 518 | replaced with start and end indices in ``self.specs``. |
| 519 | |
| 520 | :return: self. |
| 521 | ''' |
| 522 | self.type(list) |
| 523 | |
| 524 | max_len = len(specs) |
| 525 | min_len = max_len |
| 526 | for spec in reversed(specs): |
| 527 | if spec.isoptional: |
| 528 | min_len -= 1 |
| 529 | else: |
| 530 | break |
| 531 | if max_len == min_len: |
| 532 | self.len('eq', len(specs)) |
| 533 | else: |
| 534 | if min_len > 0: |
| 535 | self.len('ge', min_len) |
| 536 | self.len('le', max_len) |
| 537 | |
| 538 | start = len(self.specs) |
| 539 | for i, spec in zip(itertools.count(), specs): |
| 540 | self.specs.append(spec) |
| 541 | self.checks.append(('check_tuple', start, len(self.specs))) |
| 542 | return self |
| 543 | |
| 544 | def func(self, func, msg_func=None): |
| 545 | '''Describe value that is checked by the given function |
no test coverage detected