Пример #1
0
def test_reprhandler():
    a = A()
    s = reprhandler(a.foo)
    assert s == "<handler[*][foo] (A.foo)>"

    f = lambda: None
    pytest.raises(AttributeError, reprhandler, f)
Пример #2
0
def inspect(x):
    """Display an inspection report of the Component or Manager x

    :param x: A Component or Manager to graph
    :type  x: Component or Manager

    @return: A detailed inspection report of x
    @rtype:  str
    """

    s = []
    write = s.append

    write(" Components: %d\n" % len(x.components))
    for component in x.components:
        write("  %s\n" % component)
    write("\n")

    from circuits import reprhandler

    write(" Event Handlers: %d\n" % len(x._handlers.values()))
    for event, handlers in x._handlers.items():
        write("  %s; %d\n" % (event, len(x._handlers[event])))
        for handler in x._handlers[event]:
            write("   %s\n" % reprhandler(handler))

    return "".join(s)
Пример #3
0
	def _on_exception(self, *args, **kwargs):
		fevent = kwargs['fevent']
		if fevent.name == '_read':
			socket = fevent.args[0]
			self.fire(close(socket))
		elif isinstance(fevent, (read, RequestEvent, ResponseEvent, HTTPError)):
			pass  # already handled
		elif fevent.name == 'response.body':
			socket = fevent.args[0].socket
			self.fire(close(socket))
		elif fevent.name == 'httperror_success':
			self._on_httperror_failure(fevent.args[0], args)
		else:
			# TODO: log
			handler = reprhandler(kwargs['handler']) if kwargs['handler'] else 'Unknown'
			print('Exception in %s\nTraceback: %s' % (handler, ''.join(args[2])))
Пример #4
0
    def _on_error(self, error_type, value, traceback, handler=None, fevent=None):
        s = []

        if handler is None:
            handler = ""
        else:
            handler = reprhandler(handler)

        msg = "ERROR %s (%s) {%s}: %s\n" % (handler, fevent, error_type, value)
        s.append(msg)
        s.extend(traceback)
        s.append("\n")
        self.test_result = "".join(s)
        self.test_result = False
        print 'Stopping - error.'
        self.root.stop()