result = method.defaultTestResult() method.run(result) if result.errors: assert len(result.errors) print result.errors[0][1] if result.failures: assert len(result.failures) print result.failures[0][1] if result.failures or result.errors: return 1 def set_argv(filename): sys.argv[:] = ['python', filename] ''') intercept_test_support = app.interphook('intercept_test_support') collect_intercepted = app.interphook('collect_intercepted') run_testcase_method = app.interphook('run_testcase_method') set_argv = app.interphook('set_argv') def start_intercept(space): w_suites, w_doctestmodules = space.unpacktuple(intercept_test_support(space)) return w_suites, w_doctestmodules def collect_intercept(space, w_suites, w_doctestmodules): w_result = callex(space, collect_intercepted, space, w_suites, w_doctestmodules) w_namemethods, w_doctestlist = space.unpacktuple(w_result) return w_namemethods, w_doctestlist class SimpleRunItem(py.test.collect.Item): """ Run a module file and compare its output
@unwrap_spec(name=str, startfrom=int) def call_method(self, name, w_args, startfrom=0): return call_method(self.space, self.b_obj, self.b_obj.GetType(), name, w_args, startfrom) @unwrap_spec(typename=str) def cli_object_new(space, w_subtype, typename, w_args): b_type = System.Type.GetType(typename) b_args, b_paramtypes = rewrap_args(space, w_args, 0) b_ctor = get_constructor(space, b_type, b_paramtypes) try: b_obj = b_ctor.Invoke(b_args) except TargetInvocationException, e: b_inner = native_exc(e).get_InnerException() message = str(b_inner.get_Message()) # TODO: use the appropriate exception, not StandardError raise OperationError(space.w_StandardError, space.wrap(message)) return space.wrap(W_CliObject(space, b_obj)) W_CliObject.typedef = TypeDef( '_CliObject_internal', __new__ = interp2app(cli_object_new), call_method = interp2app(W_CliObject.call_method), ) path, _ = os.path.split(__file__) app_clr = os.path.join(path, 'app_clr.py') app = ApplevelClass(file(app_clr).read()) del path, app_clr build_wrapper = app.interphook("build_wrapper") wrapper_from_cliobj = app.interphook("wrapper_from_cliobj")
def call_method(self, name, w_args, startfrom=0): return call_method(self.space, self.b_obj, self.b_obj.GetType(), name, w_args, startfrom) call_method.unwrap_spec = ['self', str, W_Root, int] def cli_object_new(space, w_subtype, typename, w_args): b_type = System.Type.GetType(typename) b_args, b_paramtypes = rewrap_args(space, w_args, 0) b_ctor = get_constructor(space, b_type, b_paramtypes) try: b_obj = b_ctor.Invoke(b_args) except TargetInvocationException, e: b_inner = native_exc(e).get_InnerException() message = str(b_inner.get_Message()) # TODO: use the appropriate exception, not StandardError raise OperationError(space.w_StandardError, space.wrap(message)) return space.wrap(W_CliObject(space, b_obj)) cli_object_new.unwrap_spec = [ObjSpace, W_Root, str, W_Root] W_CliObject.typedef = TypeDef( '_CliObject_internal', __new__ = interp2app(cli_object_new), call_method = interp2app(W_CliObject.call_method), ) path, _ = os.path.split(__file__) app_clr = os.path.join(path, 'app_clr.py') app = ApplevelClass(file(app_clr).read()) del path, app_clr build_wrapper = app.interphook("build_wrapper") wrapper_from_cliobj = app.interphook("wrapper_from_cliobj")
def call_method(self, name, w_args, startfrom=0): return call_method(self.space, self.b_obj, self.b_obj.GetType(), name, w_args, startfrom) call_method.unwrap_spec = ['self', str, W_Root, int] def cli_object_new(space, w_subtype, typename, w_args): b_type = System.Type.GetType(typename) b_args, b_paramtypes = rewrap_args(space, w_args, 0) b_ctor = get_constructor(space, b_type, b_paramtypes) try: b_obj = b_ctor.Invoke(b_args) except TargetInvocationException, e: b_inner = native_exc(e).get_InnerException() message = str(b_inner.get_Message()) # TODO: use the appropriate exception, not StandardError raise OperationError(space.w_StandardError, space.wrap(message)) return space.wrap(W_CliObject(space, b_obj)) cli_object_new.unwrap_spec = [ObjSpace, W_Root, str, W_Root] W_CliObject.typedef = TypeDef( '_CliObject_internal', __new__ = interp2app(cli_object_new), call_method = interp2app(W_CliObject.call_method), ) path, _ = os.path.split(__file__) app_clr = os.path.join(path, 'app_clr.py') app = ApplevelClass(file(app_clr).read()) del path, app_clr build_wrapper = app.interphook("build_wrapper")