_apycotlib/narvalactions.py
author David Douard <david.douard@logilab.fr>
Thu, 13 Nov 2014 14:34:08 +0100
changeset 1743 a9b471081580
parent 1736 72ec6c7e956c
child 1586 932909726c46
permissions -rw-r--r--
[atest] ensure an error in a recipe execution (even a SyntaxError) is reported instead of crashing the process

from apycotlib import atest, writer, ERROR

class apycot_environment(object):
    def __init__(self, plan):
        self.plan = plan

    def __enter__(self):
        w  = writer.TestDataWriter(self.plan.cnxh, self.plan.plandata['eid'])
        test = atest.Test(self.plan.plandata, w)
        test.setup()
        self.test = test
        return test

    def __exit__(self, exc_type, exc_val, exc_tb):
        if exc_type is not None:
            self.test.global_status = ERROR
        self.test.clean()

def install_environment(test):
    data = test.writer.cnxh.rql('Any E WHERE E eid %s' % test.texec['eid'],
                                vid='apycot.get_dependencies').json()
    for dep in data[0]:
        test.checkout(dep)
        test.call_preprocessor('install', dep)