Пример #1
0
 def _validate_no_named_only_missing(self, named, spec):
     defined = set(named) | set(spec.defaults)
     missing = [arg for arg in spec.kwonlyargs if arg not in defined]
     if missing:
         raise DataError("%s '%s' missing named-only argument%s %s." %
                         (spec.type, spec.name, plural_or_not(missing),
                          seq2str(sorted(missing))))
Пример #2
0
 def _validate_no_extra_named(self, named, spec):
     if not spec.kwargs:
         extra = set(named) - set(spec.positional) - set(spec.kwonlyargs)
         if extra:
             raise DataError("%s '%s' got unexpected named argument%s %s." %
                             (spec.type, spec.name, plural_or_not(extra),
                              seq2str(sorted(extra))))
Пример #3
0
 def _validate_no_extra_named(self, named, spec):
     if not spec.kwargs:
         extra = set(named) - set(spec.positional) - set(spec.kwonlyargs)
         if extra:
             raise DataError("%s '%s' got unexpected named argument%s %s."
                             % (spec.type, spec.name, plural_or_not(extra),
                                seq2str(sorted(extra))))
Пример #4
0
 def _validate_no_named_only_missing(self, named, spec):
     defined = set(named) | set(spec.defaults)
     missing = [arg for arg in spec.kwonlyargs if arg not in defined]
     if missing:
         raise DataError("%s '%s' missing named-only argument%s %s."
                         % (spec.type, spec.name, plural_or_not(missing),
                            seq2str(sorted(missing))))
Пример #5
0
 def start_suite(self, suite):
     if not suite.parent:
         self._stdout.write(
             "Running suite '%s' with %d %s%s.\n" %
             (suite.name, suite.test_count, 'test' if not suite.rpa else
              'task', plural_or_not(suite.test_count)))
         self._stdout.write('=' * self._width + '\n')
Пример #6
0
 def start_suite(self, suite):
     if not suite.parent:
         self._stdout.write("Running suite '%s' with %d %s%s.\n"
                            % (suite.name, suite.test_count,
                               'test' if not suite.rpa else 'task',
                               plural_or_not(suite.test_count)))
         self._stdout.write('=' * self._width + '\n')
Пример #7
0
 def report(self, suite):
     suite.visit(self)
     stats = suite.statistics
     self._stream.write("%s\nRun suite '%s' with %d test%s in %s.\n\n"
                        % ('=' * self._width, suite.name,
                           stats.all.total, plural_or_not(stats.all.total),
                           secs_to_timestr(suite.elapsedtime/1000.0)))
     self._stream.highlight(suite.status + 'ED', suite.status)
     self._stream.write('\n%s\n' % stats.message)
Пример #8
0
 def report(self, suite):
     suite.visit(self)
     stats = suite.statistics
     self._stream.write("%s\nRun suite '%s' with %d test%s in %s.\n\n" %
                        ('=' * self._width, suite.name, stats.all.total,
                         plural_or_not(stats.all.total),
                         secs_to_timestr(suite.elapsedtime / 1000.0)))
     self._stream.highlight(suite.status + 'ED', suite.status)
     self._stream.write('\n%s\n' % stats.message)
Пример #9
0
 def _raise_wrong_count(self, count, spec):
     minend = plural_or_not(spec.minargs)
     if spec.minargs == spec.maxargs:
         expected = '%d argument%s' % (spec.minargs, minend)
     elif not spec.varargs:
         expected = '%d to %d arguments' % (spec.minargs, spec.maxargs)
     else:
         expected = 'at least %d argument%s' % (spec.minargs, minend)
     if spec.kwargs or spec.kwonlyargs:
         expected = expected.replace('argument', 'non-named argument')
     raise DataError("%s '%s' expected %s, got %d." %
                     (spec.type, spec.name, expected, count))
Пример #10
0
 def _raise_wrong_count(self, count, spec):
     minend = plural_or_not(spec.minargs)
     if spec.minargs == spec.maxargs:
         expected = '%d argument%s' % (spec.minargs, minend)
     elif not spec.varargs:
         expected = '%d to %d arguments' % (spec.minargs, spec.maxargs)
     else:
         expected = 'at least %d argument%s' % (spec.minargs, minend)
     if spec.kwargs or spec.kwonlyargs:
         expected = expected.replace('argument', 'non-named argument')
     raise DataError("%s '%s' expected %s, got %d."
                     % (spec.type, spec.name, expected, count))
Пример #11
0
    def remove_duplicates(self, list_):
        """Returns a list without duplicates based on the given ``list``.

        Creates and returns a new list that contains all items in the given
        list so that one item can appear only once. Order of the items in
        the new list is the same as in the original except for missing
        duplicates. Number of the removed duplicates is logged.
        """
        self._validate_list(list_)
        ret = []
        for item in list_:
            if item not in ret:
                ret.append(item)
        removed = len(list_) - len(ret)
        logger.info('%d duplicate%s removed.' % (removed, plural_or_not(removed)))
        return ret
Пример #12
0
    def remove_duplicates(self, list_):
        """Returns a list without duplicates based on the given ``list``.

        Creates and returns a new list that contains all items in the given
        list so that one item can appear only once. Order of the items in
        the new list is the same as in the original except for missing
        duplicates. Number of the removed duplicates is logged.
        """
        self._validate_list(list_)
        ret = []
        for item in list_:
            if item not in ret:
                ret.append(item)
        removed = len(list_) - len(ret)
        logger.info('%d duplicate%s removed.' %
                    (removed, plural_or_not(removed)))
        return ret
 def set_if_removed(self, kw, len_before):
     removed = len_before - len(kw.keywords)
     if removed:
         self.set(kw, self._message % (removed, plural_or_not(removed)))
Пример #14
0
 def set_if_removed(self, kw, len_before):
     removed = len_before - len(kw.keywords)
     if removed:
         self.set(kw, self._message % (removed, plural_or_not(removed)))