_apycotlib/narvalactions.py
author David Douard <david.douard@logilab.fr>
Wed, 14 May 2014 22:28:57 +0200
changeset 1520 0abe241164e2
parent 1477 c91d4e6d72fd
child 1550 d77b516a8f00
permissions -rw-r--r--
[test] fix tests when executed in an apycot environment ie. when tests are executed from sources towards an installed apycot. The fix consist mainly in "moving" the input_path function from testutils.py (which is part of the installed modules) into unittest_checkers.py so we are sure we look for test data files relatively to the test directory (and not the location of the installation).

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['cwuri'])
        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):
    texec_url = test.writer.cnxh.instance_url + str(test.texec['eid'])
    data = test.writer.cnxh.http_get(texec_url, vid='apycot.get_dependencies')
    for dep in data[0]:
        test.checkout(dep)
        test.call_preprocessor('install', dep)