Exemple #1
0
def main():
    filename = 'my_script'
    dialect = MyDialect()
    script = compile(src, filename, dialect)
    result = script.run()
    assert result.exception is False
    roots = result.globals['roots']
    assert roots == [1., 2., 3., 4., 5.,],  roots
Exemple #2
0
    def test_imported_module(self):
        class MyDialect(Dialect):
            allow_statement_import = True

        filename = '<my_file>'
        src = """\
        import math
        """
        src = textwrap.dedent(src)
        script = compiler.compile(src, filename, MyDialect)
        result = script.run()
        globals = result.globals
        self.assertFalse(isinstance(result.globals['math'], types.ModuleType))
        self.assertTrue(isinstance(result.globals['math'], ModuleWrapper))
Exemple #3
0
def main():
    filename = 'my_script'
    dialect = Dialect()
    script = compile(src, filename, dialect)
    result = script.run()
    assert result.exception is False