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

Code before:
            assert self.console.log.lines == ["hello"]
            self.assert_no_banners()
        else:
            # XXX adapt and fix the test
            expected_alert_banner_msg = (
                '(PY1000): When execution_thread is "worker", the site must be cross origin '
                "isolated, but crossOriginIsolated is false. To be cross origin isolated, "
                "the server must use https and also serve with the following headers: "
                '{"Cross-Origin-Embedder-Policy":"require-corp",'
                '"Cross-Origin-Opener-Policy":"same-origin"}. '
                "The problem may be that one or both of these are missing."
            )
            alert_banner = self.page.wait_for_selector(".py-error")
            assert expected_alert_banner_msg in alert_banner.inner_text()

    def test_print(self):
        self.pyscript_run(
            """
            <script type="py">
                print('hello pyscript')
            </script>
            """
        )
        assert self.console.log.lines[-1] == "hello pyscript"

    @skip_worker("input does not raise exceptions in workers")
    def test_input_exception(self):
        self.pyscript_run(
            """
            <script type="py">
                input("what's your name?")
            </script>
            """
        )
        self.check_py_errors(
            "Exception: input() doesn't work when PyScript runs in the main thread."
        )

    @skip_worker("NEXT: exceptions should be displayed in the DOM")
    def test_python_exception(self):
        self.pyscript_run(
            """
            <script type="py">
                print('hello pyscript')
                raise Exception('this is an error')
            </script>
        """
        )
        assert "hello pyscript" in self.console.log.lines
        self.check_py_errors("Exception: this is an error")
        #

Review comment (bug):
this should be a `@only_main` IMHO.

In my view, "skip" means "this test currently fails but only temporarily, we will fix it"

Code after:
            assert self.console.log.lines == ["hello"]
            self.assert_no_banners()
        else:
            # XXX adapt and fix the test
            expected_alert_banner_msg = (
                '(PY1000): When execution_thread is "worker", the site must be cross origin '
                "isolated, but crossOriginIsolated is false. To be cross origin isolated, "
                "the server must use https and also serve with the following headers: "
                '{"Cross-Origin-Embedder-Policy":"require-corp",'
                '"Cross-Origin-Opener-Policy":"same-origin"}. '
                "The problem may be that one or both of these are missing."
            )
            alert_banner = self.page.wait_for_selector(".py-error")
            assert expected_alert_banner_msg in alert_banner.inner_text()

    def test_print(self):
        self.pyscript_run(
            """
            <script type="py">
                print('hello pyscript')
            </script>
            """
        )
        assert self.console.log.lines[-1] == "hello pyscript"

    @only_main
    def test_input_exception(self):
        self.pyscript_run(
            """
            <script type="py">
                input("what's your name?")
            </script>
            """
        )
        self.check_py_errors(
            "Exception: input() doesn't work when PyScript runs in the main thread."
        )

    @skip_worker("NEXT: exceptions should be displayed in the DOM")
    def test_python_exception(self):
        self.pyscript_run(
            """
            <script type="py">
                print('hello pyscript')
                raise Exception('this is an error')
            </script>
        """
        )
        assert "hello pyscript" in self.console.log.lines
        self.check_py_errors("Exception: this is an error")
        #