Exemplo n.º 1
0
def test_script_exception():
    with tutils.chdir(tutils.test_data.path("scripts")):
        s = Script("syntaxerr.py", None)
        with tutils.raises(ScriptException):
            s.load()

        s = Script("starterr.py", None)
        with tutils.raises(ScriptException):
            s.load()

        s = Script("a.py", None)
        s.load()
        with tutils.raises(ScriptException):
            s.load()

        s = Script("a.py", None)
        with tutils.raises(ScriptException):
            s.run("here")

        with tutils.raises(ScriptException):
            with Script("reqerr.py", None) as s:
                s.run("request", None)

        s = Script("unloaderr.py", None)
        s.load()
        with tutils.raises(ScriptException):
            s.unload()
Exemplo n.º 2
0
def test_script_exception():
    with tutils.chdir(tutils.test_data.path("data/scripts")):
        s = Script("syntaxerr.py", None)
        with tutils.raises(ScriptException):
            s.load()

        s = Script("starterr.py", None)
        with tutils.raises(ScriptException):
            s.load()

        s = Script("a.py", None)
        s.load()
        with tutils.raises(ScriptException):
            s.load()

        s = Script("a.py", None)
        with tutils.raises(ScriptException):
            s.run("here")

        with tutils.raises(ScriptException):
            with Script("reqerr.py", None) as s:
                s.run("request", None)

        s = Script("unloaderr.py", None)
        s.load()
        with tutils.raises(ScriptException):
            s.unload()
Exemplo n.º 3
0
 def test_parse_windows(self):
     with tutils.chdir(tutils.test_data.dirname):
         assert Script.parse_command("data\\scripts\\a.py") == [
             "data\\scripts\\a.py"
         ]
         assert Script.parse_command(
             "data\\scripts\\a.py 'foo \\ bar'") == [
                 "data\\scripts\\a.py", 'foo \\ bar'
             ]
Exemplo n.º 4
0
 def test_parse_args(self):
     with tutils.chdir(tutils.test_data.dirname):
         assert Script.parse_command("scripts/a.py") == ["scripts/a.py"]
         assert Script.parse_command("scripts/a.py foo bar") == [
             "scripts/a.py", "foo", "bar"
         ]
         assert Script.parse_command("scripts/a.py 'foo bar'") == [
             "scripts/a.py", "foo bar"
         ]
Exemplo n.º 5
0
def test_simple():
    with tutils.chdir(tutils.test_data.path("scripts")):
        s = Script("a.py --var 42", None)
        assert s.filename == "a.py"
        assert s.ns is None

        s.load()
        assert s.ns["var"] == 42

        s.run("here")
        assert s.ns["var"] == 43

        s.unload()
        assert s.ns is None

        with tutils.raises(ScriptException):
            s.run("here")

        with Script("a.py --var 42", None) as s:
            s.run("here")
Exemplo n.º 6
0
def test_simple():
    with tutils.chdir(tutils.test_data.path("data/scripts")):
        s = Script("a.py --var 42", None)
        assert s.filename == "a.py"
        assert s.ns is None

        s.load()
        assert s.ns["var"] == 42

        s.run("here")
        assert s.ns["var"] == 43

        s.unload()
        assert s.ns is None

        with tutils.raises(ScriptException):
            s.run("here")

        with Script("a.py --var 42", None) as s:
            s.run("here")
Exemplo n.º 7
0
 def test_parse_windows(self):
     with tutils.chdir(tutils.test_data.dirname):
         assert Script.parse_command("scripts\\a.py") == ["scripts\\a.py"]
         assert Script.parse_command("scripts\\a.py 'foo \\ bar'") == ["scripts\\a.py", 'foo \\ bar']
Exemplo n.º 8
0
 def test_parse_args(self):
     with tutils.chdir(tutils.test_data.dirname):
         assert Script.parse_command("scripts/a.py") == ["scripts/a.py"]
         assert Script.parse_command("scripts/a.py foo bar") == ["scripts/a.py", "foo", "bar"]
         assert Script.parse_command("scripts/a.py 'foo bar'") == ["scripts/a.py", "foo bar"]