def forked_run_report(item): # for now, we run setup/teardown in the subprocess # XXX optionally allow sharing of setup/teardown EXITSTATUS_TESTEXIT = 4 from py.__.test.dist.mypickle import ImmutablePickler ipickle = ImmutablePickler(uneven=0) ipickle.selfmemoize(item.config) # XXX workaround the issue that 2.6 cannot pickle # instances of classes defined in global conftest.py files ipickle.selfmemoize(item) def runforked(): try: reports = runtestprotocol(item, log=False) except KeyboardInterrupt: py.std.os._exit(EXITSTATUS_TESTEXIT) return ipickle.dumps(reports) ff = py.process.ForkedFunc(runforked) result = ff.waitfinish() if result.retval is not None: return ipickle.loads(result.retval) else: if result.exitstatus == EXITSTATUS_TESTEXIT: py.test.exit("forked test item %s raised Exit" % (item, )) return [report_process_crash(item, result)]
def forked_run_report(item): # for now, we run setup/teardown in the subprocess # XXX optionally allow sharing of setup/teardown EXITSTATUS_TESTEXIT = 4 from py.__.test.dist.mypickle import ImmutablePickler ipickle = ImmutablePickler(uneven=0) ipickle.selfmemoize(item.config) # XXX workaround the issue that 2.6 cannot pickle # instances of classes defined in global conftest.py files ipickle.selfmemoize(item) def runforked(): try: reports = runtestprotocol(item, log=False) except KeyboardInterrupt: py.std.os._exit(EXITSTATUS_TESTEXIT) return ipickle.dumps(reports) ff = py.process.ForkedFunc(runforked) result = ff.waitfinish() if result.retval is not None: return ipickle.loads(result.retval) else: if result.exitstatus == EXITSTATUS_TESTEXIT: py.test.exit("forked test item %s raised Exit" %(item,)) return [report_process_crash(item, result)]
def forked_run_report(item, pdb=None): EXITSTATUS_TESTEXIT = 4 ipickle = ImmutablePickler(uneven=0) ipickle.selfmemoize(item.config) def runforked(): try: testrep = basic_run_report(item) except (KeyboardInterrupt, Exit): os._exit(EXITSTATUS_TESTEXIT) return ipickle.dumps(testrep) ff = py.process.ForkedFunc(runforked) result = ff.waitfinish() if result.retval is not None: return ipickle.loads(result.retval) else: if result.exitstatus == EXITSTATUS_TESTEXIT: raise Exit("forked test item %s raised Exit" %(item,)) return report_process_crash(item, result)
def test_self_memoize(): p1 = ImmutablePickler(uneven=False) a1 = A() p1.selfmemoize(a1) x = p1.loads(p1.dumps(a1)) assert x is a1