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

Code before:
            "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'
        )

    @pytest.mark.skip(reason="pys-onClick is broken, we should kill it")
    def test_pys_onClick_shows_deprecation_warning(self):
        self.pyscript_run(
            """
            <button id="1" pys-onClick="myfunc()">Click me</button>
            <py-script>
                def myfunc():
                    print("hello world")

            </py-script>
            """
        )
        banner = self.page.locator(".alert-banner")
        expected_message = (
            "The attribute 'pys-onClick' and 'pys-onKeyDown' are "
            "deprecated. Please 'py-click=\"myFunction()\"' or "
            "'py-keydown=\"myFunction()\"' instead."
        )
        assert banner.inner_text() == expected_message

    def test_py_attribute_without_id(self):
        self.pyscript_run(
            """
            <button py-click="myfunc()">Click me</button>
            <py-script>
                def myfunc():

Review comment (suggestion):
we should make sure to open an issue so that we don't forget (and ideally include the issue number in the `reason`)

Code after:
            "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'
        )

    @pytest.mark.skip(reason="pys-onClick is broken, we should kill it, see #1213")
    def test_pys_onClick_shows_deprecation_warning(self):
        self.pyscript_run(
            """
            <button id="1" pys-onClick="myfunc()">Click me</button>
            <py-script>
                def myfunc():
                    print("hello world")

            </py-script>
            """
        )
        banner = self.page.locator(".alert-banner")
        expected_message = (
            "The attribute 'pys-onClick' and 'pys-onKeyDown' are "
            "deprecated. Please 'py-click=\"myFunction()\"' or "
            "'py-keydown=\"myFunction()\"' instead."
        )
        assert banner.inner_text() == expected_message

    def test_py_attribute_without_id(self):
        self.pyscript_run(
            """
            <button py-click="myfunc()">Click me</button>
            <py-script>
                def myfunc():