Ejemplo n.º 1
0
def test_db_files(db, tmpdir, mocker):
    sess = Session([Cache(db), FileManager(tmpdir)])
    with sess:
        sess.eval(analysis(calcs2()))
    mocker.patch.object(sess, 'run_task')
    with sess:
        sess.eval(analysis(calcs2()))
        assert not sess.run_task.called
Ejemplo n.º 2
0
def test_db(db, mocker):
    sess = Session([Cache(db)])
    with sess:
        sess.eval(analysis(calcs()))
    mocker.patch.object(sess, 'run_task')
    with sess:
        assert sess.eval(analysis(calcs())) == 20
        assert not sess.run_task.called
Ejemplo n.º 3
0
def test_postponed(db):
    cache = Cache(db, write='on_exit')
    sess = Session([cache])
    with sess:
        sess.eval(analysis(calcs()), task_filter=lambda t: t.label[0] != '/')
        assert len(cache._objects) == 23
    assert not cache._objects
Ejemplo n.º 4
0
def test_exception():
    def handler(task, exc):
        if isinstance(exc, subprocess.CalledProcessError):
            return True

    with Session([Parallel()]) as sess:
        sess.eval(analysis(calcs('x')), exception_handler=handler)
Ejemplo n.º 5
0
def test_calc():
    with Session([Parallel()]) as sess:
        assert sess.eval(analysis(calcs(0))) == 20
Ejemplo n.º 6
0
def test_basic(tmpdir):
    with Session([TmpdirManager(tmpdir)]) as sess:
        assert sess.eval(analysis(calcs())) == 20