getPySrc should return source code (#1041)

* getPySrc should return source code

* fix lint

* add test

* fix dynamic tag test

* address feedback
This commit is contained in:
Madhur Tandon
2022-12-13 02:41:21 +05:30
committed by GitHub
parent 4f05b5afc6
commit 08e83feaf5
2 changed files with 23 additions and 1 deletions

View File

@@ -276,3 +276,19 @@ class TestBasic(PyScriptTest):
"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'
)