Beispiel #1
0
def test_with_lifelib(testpaths, project):

    build_path, write_path = testpaths

    from lifelib.commands import create

    testproj = project + "_test"
    projpath = build_path / testproj

    create.main([
        "--template",
        project,
        str(projpath)
    ])

    with SysPath(str(projpath.parent)):

        module = importlib.import_module(testproj + "." + project)

        with SysPath(str(projpath)):

            m = module.build()
            m.hoge = "hoge"
            m.foo = 1
            m.bar = m.Input
            m.Input.new_cells(formula=lambda x: 3 * x)
            m.none = None

            write_model(m, str(write_path / project))
            m2 = read_model(str(write_path / project))
            testutil.compare_model(m, m2)

    _PROJECTS[project](m, m2)
Beispiel #2
0
def test_main(argv, tmp_path):
    tempdir = str(tmp_path / 'mylife')

    argv.append(tempdir)
    cmd.main(argv)

    while True:
        try:
            shutil.rmtree(tempdir)
            break
        except (PermissionError, OSError):
            pass

    assert True
Beispiel #3
0
def test_main(argv):
    tempdir = os.path.join(os.path.abspath(os.path.dirname(__file__)),
                           'mylife')

    if os.path.exists(tempdir):
        shutil.rmtree(tempdir)

    argv.append(tempdir)
    cmd.main(argv)

    while True:
        try:
            shutil.rmtree(tempdir)
            break
        except (PermissionError, OSError):
            pass

    assert True
Beispiel #4
0
def test_with_lifelib(testpaths, project):

    build_path, write_path, zip_path = testpaths

    import lifelib

    testproj = project + "_test"
    projpath = build_path / testproj

    if lifelib.VERSION > (0, 0, 14):
        lifelib.create(project, projpath)
        scriptpath = projpath / "scripts"
    else:
        from lifelib.commands import create
        create.main(["--template", project, str(projpath)])
        scriptpath = projpath.parent

    with SysPath(str(scriptpath)):

        if lifelib.VERSION > (0, 0, 14):
            module = importlib.import_module(project)
        else:
            module = importlib.import_module(testproj + "." + project)

        with SysPath(str(projpath)):

            m = module.build()
            m.hoge = "hoge"
            m.foo = 1
            m.bar = m.Input
            m.Input.new_cells(formula=lambda x: 3 * x)
            m.none = None

            mx.write_model(m, str(write_path / project))
            mx.zip_model(m, str(zip_path / project))

            m2 = mx.read_model(str(write_path / project))
            testutil.compare_model(m, m2)

            m3 = mx.read_model(str(zip_path / project))
            testutil.compare_model(m, m3)

    _PROJECTS[project](m, m2)
    _PROJECTS[project](m, m3)