def _log_args(self, positional, named): positional = [utils.prepr(arg) for arg in positional] named = [ '%s=%s' % (utils.unic(name), utils.prepr(value)) for name, value in named.items() ] return 'Arguments: [ %s ]' % ' | '.join(positional + named)
def _verify(self, item, expected=None, **config): if not expected: expected = repr(item).lstrip('') assert_equal(prepr(item, **config), expected) if isinstance(item, (str, bytes)) and not config: assert_equal(prepr([item]), '[%s]' % expected) assert_equal(prepr((item,)), '(%s,)' % expected) assert_equal(prepr({item: item}), '{%s: %s}' % (expected, expected)) assert_equal(prepr({item}), '{%s}' % expected)
def _verify(self, item, expected=None, **config): if not expected: expected = repr(item).lstrip('u') assert_equal(prepr(item, **config), expected) if isinstance(item, (unicode, bytes)) and not config: assert_equal(prepr([item]), '[%s]' % expected) assert_equal(prepr((item,)), '(%s,)' % expected) assert_equal(prepr({item: item}), '{%s: %s}' % (expected, expected)) assert_equal(prepr({item}), ('{%s}' if PY3 else 'set([%s])') % expected)
def _validate_key(self, key): if isinstance(key, xmlrpclib.Binary): raise ValueError('Dictionary keys cannot be binary. Got %s.' % prepr(key.data)) if IRONPYTHON: try: key.encode('ASCII') except UnicodeError: raise ValueError('Dictionary keys cannot contain non-ASCII ' 'characters on IronPython. Got %s.' % prepr(key))
def _verify(self, item, expected=None): if not expected: expected = repr(item).lstrip('u') assert_equal(prepr(item), expected) if isinstance(item, (unicode, bytes)): assert_equal(prepr([item]), '[%s]' % expected) assert_equal(prepr((item, )), '(%s,)' % expected) assert_equal(prepr({item: item}), '{%s: %s}' % (expected, expected)) assert_equal(prepr({item}), ('{%s}' if PY3 else 'set([%s])') % expected)
def assign(self, context, return_value): self.validate_assignment() context.trace(lambda: 'Return: %s' % prepr(return_value)) resolver = ReturnValueResolver(self.assignment) for name, value in resolver.resolve(return_value): if not self._extended_assign(name, value, context.variables): value = self._normal_assign(name, value, context.variables) context.info(format_assign_message(name, value))
def _log_args(self, variables): args = ['${%s}' % arg for arg in self.arguments.positional] if self.arguments.varargs: args.append('@{%s}' % self.arguments.varargs) if self.arguments.kwargs: args.append('&{%s}' % self.arguments.kwargs) args = ['%s=%s' % (name, prepr(variables[name])) for name in args] return 'Arguments: [ %s ]' % ' | '.join(args)
def assign(self, return_value): context = self._context context.trace(lambda: 'Return: %s' % prepr(return_value)) resolver = ReturnValueResolver(self._assignment) for name, value in resolver.resolve(return_value): if not self._extended_assign(name, value, context.variables): value = self._normal_assign(name, value, context.variables) context.info(format_assign_message(name, value))
def _check_deprecations(self, cells, path, line_number): for original in cells: normalized = ' '.join(original.split()) if normalized != original: if len(normalized) != len(original): msg = 'Collapsing consecutive whitespace' else: msg = 'Converting whitespace characters to ASCII spaces' LOGGER.warn("%s during parsing is deprecated. Fix %s in file " "'%s' on line %d." % (msg, prepr(original), path, line_number)) yield normalized
def _check_deprecations(self, cells, path, line_number): for original in cells: normalized = self._normalize_whitespace(original) if normalized != original: if len(normalized) != len(original): msg = 'Collapsing consecutive whitespace' else: msg = 'Converting whitespace characters to ASCII spaces' LOGGER.warn("%s during parsing is deprecated. Fix %s in file " "'%s' on line %d." % (msg, prepr(original), path, line_number)) yield normalized
def _trace_log_args(self, positional, named): args = [prepr(arg) for arg in positional] args += ['%s=%s' % (unic(n), prepr(v)) for n, v in named] return 'Arguments: [ %s ]' % ' | '.join(args)
def _format_trace_log_args_message(self, args, variables): args = ['%s=%s' % (name, prepr(variables[name])) for name in args] return 'Arguments: [ %s ]' % ' | '.join(args)
def _log_args(self, positional, named): positional = [utils.prepr(arg) for arg in positional] named = ['%s=%s' % (utils.unic(name), utils.prepr(value)) for name, value in named] return 'Arguments: [ %s ]' % ' | '.join(positional + named)
def assign(self, context, return_value): context.trace(lambda: 'Return: %s' % prepr(return_value)) for name, value in self._return_resolver.resolve(return_value): if not self._extended_assign(name, value, context.variables): value = self._normal_assign(name, value, context.variables) context.info(format_assign_message(name, value))
def _verify(self, item, expected=None): if not expected: expected = repr(item) assert_equals(prepr(item), expected)
def _verify(self, item, expected=None): if not expected: expected = repr(item) elif IRONPYTHON and "b'" in expected: expected = expected.replace("b'", "'") assert_equals(prepr(item), expected)
def test_recursive(self): x = [1, 2] x.append(x) match = re.match(r'\[1, 2. <Recursion on list with id=\d+>\]', prepr(x)) assert_true(match is not None)
def logger(): args = [prepr(arg) for arg in positional] args += ['%s=%s' % (unic(n), prepr(v)) for n, v in named] return 'Arguments: [ %s ]' % ' | '.join(args)