Skip to content

Commit

Permalink
Fix failing tests (#978)
Browse files Browse the repository at this point in the history
  • Loading branch information
FabioRosado committed Nov 24, 2022
1 parent 061d4b3 commit cafebd6
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
1 change: 0 additions & 1 deletion examples/panel_kmeans.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
<link rel="stylesheet" href="./assets/css/examples.css" />
<link rel="stylesheet" href="./assets/prism/prism.css" />
<script defer src="./assets/prism/prism.js"></script>
<script defer src="https://pyscript.net/latest/pyscript.js"></script>
</head>

<body>
Expand Down
2 changes: 1 addition & 1 deletion examples/repl.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ <h1><b>PyScript REPL</b></h1>
[[fetch]]
files = ["./antigravity.py"]
</py-config>
<div>
<div style="margin-right: 3rem;">
<py-repl id="my-repl" auto-generate="true"> </py-repl>
</div>
</section>
Expand Down
2 changes: 1 addition & 1 deletion examples/repl2.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ <h1 class="font-semibold text-2xl ml-5">Custom REPL</h1>
[[fetch]]
files = ["./utils.py", "./antigravity.py"]
</py-config>
<div>
<div style="margin-right: 3rem;">
<py-repl id="my-repl" auto-generate="true"> </py-repl>
<div id="output" class="p-4"></div>
</div>
Expand Down
2 changes: 0 additions & 2 deletions pyscriptjs/src/plugins/splashscreen.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import type { PyScriptApp } from '../main';
import type { AppConfig } from '../pyconfig';
import type { UserError } from '../exceptions';
import type { Runtime } from '../runtime';
Expand Down Expand Up @@ -44,7 +43,6 @@ export class SplashscreenPlugin extends Plugin {
customElements.define('py-splashscreen', PySplashscreen);
this.elem = <PySplashscreen>document.createElement('py-splashscreen');
document.body.append(this.elem);

document.addEventListener("py-status-message", (e: CustomEvent) => {
const msg = e.detail;
this.elem.log(msg);
Expand Down
17 changes: 10 additions & 7 deletions pyscriptjs/tests/integration/test_zz_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,14 @@ def test_matplotlib(self):
assert self.page.title() == "Matplotlib"
wait_for_render(self.page, "*", "<img src=['\"]data:image")
# The image is being rended using base64, lets fetch its source
# and replace everything but the actual base64 string.\
img_src = (
self.page.wait_for_selector("img")
.get_attribute("src")
.replace("data:image/png;charset=utf-8;base64,", "")
# and replace everything but the actual base64 string.
# Note: The first image on the page is the logo, so we are lookin
# at the mpl-1 div which is rendered once the image is in the page
# if this test fails, confirm that the div has the right id using
# the --dev flag when running the tests
test = self.page.wait_for_selector("#mpl-1 >> img")
img_src = test.get_attribute("src").replace(
"data:image/png;charset=utf-8;base64,", ""
)
# Finally, let's get the np array from the previous data
img_data = np.asarray(Image.open(io.BytesIO(base64.b64decode(img_src))))
Expand Down Expand Up @@ -261,7 +264,7 @@ def test_repl(self):
wait_for_render(self.page, "*", "<py-repl.*?>")

self.page.locator("py-repl").type("display('Hello, World!')")
self.page.locator("button").click()
self.page.locator("#runButton").click()

assert self.page.locator("#my-repl-2").text_content() == "Hello, World!"

Expand All @@ -280,7 +283,7 @@ def test_repl2(self):
wait_for_render(self.page, "*", "<py-repl.*?>")
# confirm we can import utils and run one command
self.page.locator("py-repl").type("import utils\ndisplay(utils.now())")
self.page.locator("button").click()
self.page.wait_for_selector("#runButton").click()
# Make sure the output is in the page
self.page.wait_for_selector("#my-repl-1-1")
# utils.now returns current date time
Expand Down

0 comments on commit cafebd6

Please sign in to comment.