Repository: pyscript/pyscript
File: pyscriptjs/tests/integration/test_01_basic.py (Python)

Code before:
                # trigger various warnings
                create("div", classes="a b c")
                assert sys.__name__ == 'sys'
                dedent("")
                format_mime("")
                assert MIME_RENDERERS['text/html'] is not None
                console.log("hello")
                PyScript.loop
            </py-script>

            <div id="mydiv"></div>
            """
        )
        banner = self.page.locator(".py-warning")
        messages = banner.all_inner_texts()
        assert messages == [
            "The PyScript object is deprecated. Please use pyscript instead.",
            "Direct usage of console is deprecated. Please use js.console instead.",
            "MIME_RENDERERS is deprecated. This is a private implementation detail of pyscript. You should not use it.",  # noqa: E501
            "format_mime is deprecated. This is a private implementation detail of pyscript. You should not use it.",  # noqa: E501
            "Direct usage of dedent is deprecated. Please use from textwrap import dedent instead.",
            "Direct usage of sys is deprecated. Please use import sys instead.",
            "Direct usage of create is deprecated. Please use pyscript.create instead.",
        ]

    def test_getPySrc(self):
        self.pyscript_run(
            """
            <py-script>
                print("hello world!")
            </py-script>
            """
        )

        pyscript_tag = self.page.locator("py-script")
        assert pyscript_tag.inner_html() == ""
        assert (
            pyscript_tag.evaluate("node => node.getPySrc()")
            == 'print("hello world!")\n'
        )


Review comment (suggestion):
Small nit: what you think of this name change?

```suggestion
    def test_getPySrc_returns_code(self):
```

Code after:
                # trigger various warnings
                create("div", classes="a b c")
                assert sys.__name__ == 'sys'
                dedent("")
                format_mime("")
                assert MIME_RENDERERS['text/html'] is not None
                console.log("hello")
                PyScript.loop
            </py-script>

            <div id="mydiv"></div>
            """
        )
        banner = self.page.locator(".py-warning")
        messages = banner.all_inner_texts()
        assert messages == [
            "The PyScript object is deprecated. Please use pyscript instead.",
            "Direct usage of console is deprecated. Please use js.console instead.",
            "MIME_RENDERERS is deprecated. This is a private implementation detail of pyscript. You should not use it.",  # noqa: E501
            "format_mime is deprecated. This is a private implementation detail of pyscript. You should not use it.",  # noqa: E501
            "Direct usage of dedent is deprecated. Please use from textwrap import dedent instead.",
            "Direct usage of sys is deprecated. Please use import sys instead.",
            "Direct usage of create is deprecated. Please use pyscript.create instead.",
        ]

    def test_getPySrc_returns_source_code(self):
        self.pyscript_run(
            """
            <py-script>
                print("hello world!")
            </py-script>
            """
        )

        pyscript_tag = self.page.locator("py-script")
        assert pyscript_tag.inner_html() == ""
        assert (
            pyscript_tag.evaluate("node => node.getPySrc()")
            == 'print("hello world!")\n'
        )