Esempio n. 1
0
 def prepare(self):
     """
     Creates target_sketch.py to import the sketch's functions
     """
     with self.sketch_files.target_sketch.open('w') as fd:
         content = get_target_sketch_content(self.sketch_files)
         fd.write(content)
Esempio n. 2
0
    def test_prepare_sketch(self):
        expected_content = get_target_sketch_content(self.sketch)
        assert not self.sketch.target_sketch.exists()

        self.compiler.prepare()

        assert self.sketch.target_sketch.exists()
        with self.sketch.target_sketch.open('r') as fd:
            content = fd.read()
        assert expected_content == content
Esempio n. 3
0
    def prepare(self):
        """
        Creates target_sketch.py to import the sketch's functions
        """
        content = get_target_sketch_content(self.sketch)

        with self.sketch.target_sketch.open('w') as fd:
            fd.write(content)

        cprint.info(f"{self.sketch.target_sketch.resolve()} updated with sketch code")
def test_get_target_sketch_content():
    sketch_files = SketchFiles('foo')

    expected_template = renderers.templates.get_template(
        sketch_files.from_lib.target_sketch_template.name)
    expected_content = expected_template.render({
        'sketch_name':
        sketch_files.sketch_name,
    })
    content = renderers.get_target_sketch_content(sketch_files)

    assert expected_content == content
    assert "import foo as source_sketch" in content
Esempio n. 5
0
def test_get_transcrypt_target_sketch_content(sketch):
    with open(sketch.sketch_py, 'w') as fd:
        fd.write('content')

    expected_template = renderers.templates.get_template(
        'transcrypt/target_sketch.py.template')
    expected_content = expected_template.render({
        'sketch_name': sketch.sketch_name,
        'sketch_content': 'content'
    })
    content = renderers.get_target_sketch_content(sketch)

    assert expected_content == content
Esempio n. 6
0
def test_get_pyodide_target_sketch_content(sketch_pyodide):
    with open(sketch_pyodide.sketch_py, 'w') as fd:
        fd.write('content')

    expected_template = renderers.templates.get_template(
        'pyodide/target_sketch.js.template')
    expected_content = expected_template.render({
        'sketch_name':
        sketch_pyodide.sketch_name,
        'sketch_content':
        'content',
        'pyodide_index_url':
        'https://cdn.jsdelivr.net/pyodide/v0.18.1/full/',
    })
    content = renderers.get_target_sketch_content(sketch_pyodide)

    assert expected_content == content