コード例 #1
0
ファイル: test_runtime.py プロジェクト: fabiommendes/pytuga
def test_exec_with_locals():
    loc = {}
    glob = {}
    exec("a = 1", glob, loc)
    assert loc
    assert glob
    assert loc['a'] == 1
コード例 #2
0
ファイル: test_core.py プロジェクト: flaviocostap/pytuga
def test_compile():
    code = compile('x = raiz(0 ou 1)', '<string>', 'exec')

    D = {}
    exec(code, D, forbidden=False)
    assert D['x'] == 1

    D = {}
    exec(code, D, forbidden=False)
    assert D['x'] == 1
コード例 #3
0
ファイル: test_errors.py プロジェクト: fabiommendes/pytuga
def test_bad_syntax_raises_syntax_error(bad_syntax):
    with pytest.raises(SyntaxError):
        exec(bad_syntax)
コード例 #4
0
ファイル: test_core.py プロジェクト: flaviocostap/pytuga
def test_exec():
    D = {}
    exec('x = raiz(0 ou 1) ', D, forbidden=False)
    assert D['x'] == 1
コード例 #5
0
ファイル: test_errors.py プロジェクト: Transpyler/pytunol
def test_bad_syntax_raises_syntax_error(bad_syntax):
    with pytest.raises(SyntaxError):
        exec(bad_syntax)