Пример #1
0
    def test_err(self):
        s = flow.State()
        fm = flow.FlowMaster(None, s)
        ctx = flow.ScriptContext(fm)

        s = script.Script(["nonexistent"], ctx)
        tutils.raises("no such file", s.load)

        s = script.Script([tutils.test_data.path("scripts")], ctx)
        tutils.raises("not a file", s.load)

        s = script.Script([tutils.test_data.path("scripts/syntaxerr.py")], ctx)
        tutils.raises(script.ScriptError, s.load)

        s = script.Script([tutils.test_data.path("scripts/loaderr.py")], ctx)
        tutils.raises(script.ScriptError, s.load)
Пример #2
0
    def test_err(self):
        s = flow.State()
        fm = flow.FlowMaster(None, s)
        ctx = flow.ScriptContext(fm)

        s = script.Script("nonexistent", ctx)
        libpry.raises("no such file", s.load)

        s = script.Script("scripts", ctx)
        libpry.raises("not a file", s.load)

        s = script.Script("scripts/syntaxerr.py", ctx)
        libpry.raises(script.ScriptError, s.load)

        s = script.Script("scripts/loaderr.py", ctx)
        libpry.raises(script.ScriptError, s.load)
Пример #3
0
    def test_simple(self):
        s = flow.State()
        fm = flow.FlowMaster(None, s)
        ctx = flow.ScriptContext(fm)

        p = script.Script(os.path.join("scripts", "a.py"), ctx)
        p.load()
        assert "here" in p.ns
        assert p.run("here") == (True, 1)
        assert p.run("here") == (True, 2)

        ret = p.run("errargs")
        assert not ret[0]
        assert len(ret[1]) == 2

        # Check reload
        p.load()
        assert p.run("here") == (True, 1)
Пример #4
0
    def test_simple(self):
        s = flow.State()
        fm = flow.FlowMaster(None, s)
        ctx = flow.ScriptContext(fm)

        p = script.Script(
            shlex.split(tutils.test_data.path("scripts/a.py") + " --var 40",
                        posix=(os.name != "nt")), ctx)
        p.load()

        assert "here" in p.ns
        assert p.run("here") == (True, 41)
        assert p.run("here") == (True, 42)

        ret = p.run("errargs")
        assert not ret[0]
        assert len(ret[1]) == 2

        # Check reload
        p.load()
        assert p.run("here") == (True, 41)