def inject_default_namespace(self, stackframe=None): """ Adds the default namespace to the frame, or if no frame is provided, self.curframe is used. """ stackframe = stackframe or self.curframe to_remove = set() for k, v in items(self.default_namespace): if k not in stackframe.f_globals: # Only add the default things if the name is unbound. stackframe.f_globals[k] = v to_remove.add(k) try: yield stackframe finally: for k in to_remove: try: del stackframe.f_globals[k] except IndexError: # The body of this manager might have del'd this. pass # Prevent exceptions from generating ref cycles. del stackframe
def __new__(mcls, name, bases, dict_): return super(Py2TestMeta, mcls).__new__( mcls, name, bases, {k: skip_py3(v) if k.startswith('test_') else v for k, v in items(dict_)} )
def send_watchlist(self, tracer): """ Sends the watchlist event. """ self.send_event( 'watchlist', [{'expr': k, 'exc': exc, 'value': val} for k, (exc, val) in items(tracer.watchlist)], )
def do_locals(self, arg, tracer): """ locals Report back the current stackframe's locals. """ self.writeln('locals: [') for p in items(tracer.curframe_locals): self.writeln(' %s=%s' % p) self.writeln(']') return self.next_command.tailcall(tracer)
def __new__(mcls, name, bases, dict_): return super(Py2TestMeta, mcls).__new__( mcls, name, bases, { k: skip_py3(v) if k.startswith('test_') else v for k, v in items(dict_) })