Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Update test suite #2181

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 31 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
6650809
WiP pyscript.web tests pass with upytest.
ntoll Sep 10, 2024
ec20298
Test refactoring. WiP
ntoll Sep 13, 2024
762ae19
Completed refactor of old integration tests to new Python tests.
ntoll Sep 17, 2024
b35fb8f
Added comprehensive test suite for Python based pyodide module.
ntoll Sep 19, 2024
806e574
Black.
ntoll Sep 19, 2024
177cbb9
Rebuld and check websocket attribute assignment via init and as attri…
ntoll Sep 23, 2024
091da6e
Update when tests to allow for worker round trips.
ntoll Sep 23, 2024
4a6c5fa
Post build
ntoll Sep 23, 2024
790fd26
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 23, 2024
ae66d13
Fixed config issue via polyscript update (#2182)
WebReflection Sep 24, 2024
e3c572d
WiP pyscript.web tests pass with upytest.
ntoll Sep 10, 2024
aa83e6c
Test refactoring. WiP
ntoll Sep 13, 2024
263f1fc
Completed refactor of old integration tests to new Python tests.
ntoll Sep 17, 2024
0eb8c43
Added comprehensive test suite for Python based pyodide module.
ntoll Sep 19, 2024
6c81b5f
Black.
ntoll Sep 19, 2024
43f25fd
Rebuld and check websocket attribute assignment via init and as attri…
ntoll Sep 23, 2024
344e54a
Update when tests to allow for worker round trips.
ntoll Sep 23, 2024
f24a2cf
Post build
ntoll Sep 23, 2024
6e52918
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 23, 2024
06216ac
Merge branch 'update-test-suite' of github.com:pyscript/pyscript into…
ntoll Sep 24, 2024
abc3a3b
Fix a couple of timing issues in display and web tests.
ntoll Sep 24, 2024
0d7ef9d
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 24, 2024
57e023e
Black
ntoll Sep 24, 2024
58d905d
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 24, 2024
7da2ba6
Add integration tests to Makefile (and CI)
ntoll Sep 24, 2024
f826d0b
Remove un-needed upload action.
ntoll Sep 24, 2024
af6cc2b
Ensure fails are properly logged as an array. Remove the explicit tes…
ntoll Sep 24, 2024
aa70295
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 24, 2024
19bc612
Directory reorg/refactor. Updated docs.
ntoll Sep 25, 2024
60622c9
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 25, 2024
c52a695
Bump polyscript.
ntoll Sep 25, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] authored and ntoll committed Sep 24, 2024
commit 6e52918a1f10134845848fb750f70de19edc9698
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ A simple JavaScript module to test the integration with Python.

export function hello() {
return "Hello from JavaScript!";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ A simple JavaScript module to test the integration with Python on a worker.

export function hello() {
return "Hello from JavaScript in a web worker!";
}
}
2 changes: 1 addition & 1 deletion 2 pyscript.core/tests/integration/python/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ if (config) script.setAttribute('config', config);
script.toggleAttribute('terminal', terminal);
script.toggleAttribute('worker', worker);

document.write(script.outerHTML);
document.write(script.outerHTML);
24 changes: 12 additions & 12 deletions 24 pyscript.core/tests/integration/python/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,32 +14,32 @@
<template id="test_card_with_element_template">
<p>This is a test. {foo}</p>
</template>

<div id="test_id_selector" style="visibility: hidden;">You found test_id_selector</div>
<div id="test_class_selector" class="a-test-class" style="visibility: hidden;">You found test_class_selector</div>
<div id="test_selector_w_children" class="a-test-class" style="visibility: hidden;">
<div id="test_selector_w_children_child_1" class="a-test-class" style="visibility: hidden;">Child 1</div>
<div id="test_selector_w_children_child_2" style="visibility: hidden;">Child 2</div>
</div>

<div id="div-no-classes"></div>

<div style="visibility: hidden;">
<h2>Test Read and Write</h2>
<div id="test_rr_div">Content test_rr_div</div>
<h3 id="test_rr_h3">Content test_rr_h3</h3>

<div id="multi-elem-div" class="multi-elems">Content multi-elem-div</div>
<p id="multi-elem-p" class="multi-elems">Content multi-elem-p</p>
<h2 id="multi-elem-h2" class="multi-elems">Content multi-elem-h2</h2>

<form>
<input id="test_rr_input_text" type="text" value="Content test_rr_input_text">
<input id="test_rr_input_button" type="button" value="Content test_rr_input_button">
<input id="test_rr_input_email" type="email" value="Content test_rr_input_email">
<input id="test_rr_input_password" type="password" value="Content test_rr_input_password">
</form>

<select id="test_select_element"></select>
<select id="test_select_element_w_options">
<option value="1">Option 1</option>
Expand All @@ -50,27 +50,27 @@ <h2 id="multi-elem-h2" class="multi-elems">Content multi-elem-h2</h2>
<option value="2">Option 2</option>
<option value="4">Option 4</option>
</select>

<select id="test_select_element_to_remove">
<option value="1">Option 1</option>
<option value="2">Option 2</option>
<option value="3">Option 3</option>
<option value="4">Option 4</option>
</select>

<div id="element-creation-test"></div>

<button id="a-test-button">I'm a button to be clicked</button>
<button>I'm another button you can click</button>
<button id="a-third-button">2 is better than 3 :)</button>

<div id="element-append-tests"></div>
<p class="collection"></p>
<div class="collection"></div>
<h3 class="collection"></h3>

<div id="element_attribute_tests"></div>
</div>
<div id="test-element-container"></div>
</body>
</html>
</html>
7 changes: 4 additions & 3 deletions 7 pyscript.core/tests/integration/python/main.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from pyscript import web
import upytest
import json

result = await upytest.run("./tests") #/test_web.py::TestElements.test_img")
import upytest
from pyscript import web

result = await upytest.run("./tests") # /test_web.py::TestElements.test_img")
output = web.div(json.dumps(result), id="result")
web.page.append(output)
2 changes: 1 addition & 1 deletion 2 pyscript.core/tests/integration/python/mini-coi.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@
});
}
})(self);

2 changes: 1 addition & 1 deletion 2 pyscript.core/tests/integration/python/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@
"./example_js_worker_module.js": "greeting_worker"
}
}
}
}
6 changes: 2 additions & 4 deletions 6 pyscript.core/tests/integration/python/tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Tests for the pyscript.config dictionary.
"""

from pyscript import config, fetch, document
from pyscript import config, document, fetch


async def test_config_reads_expected_settings_correctly():
Expand All @@ -15,6 +15,4 @@ async def test_config_reads_expected_settings_correctly():
url = document.location.href.rsplit("/", 1)[0] + "/settings.json"
raw_config = await fetch(url).json()
for key, value in raw_config.items():
assert (
config[key] == value
), f"Expected {key} to be {value}, got {config[key]}"
assert config[key] == value, f"Expected {key} to be {value}, got {config[key]}"
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
element's id.
"""

from pyscript import current_target, RUNNING_IN_WORKER
from pyscript import RUNNING_IN_WORKER, current_target
from upytest import is_micropython


Expand All @@ -19,6 +19,4 @@ def test_current_target():
expected = "mpy-0"
elif RUNNING_IN_WORKER:
expected = "py-w0-target"
assert (
current_target() == expected
), f"Expected {expected} got {current_target()}"
assert current_target() == expected, f"Expected {expected} got {current_target()}"
8 changes: 2 additions & 6 deletions 8 pyscript.core/tests/integration/python/tests/test_display.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
"""

import upytest


from pyscript import display, web, HTML, RUNNING_IN_WORKER, py_import
from pyscript import HTML, RUNNING_IN_WORKER, display, py_import, web


def get_display_container():
Expand Down Expand Up @@ -50,9 +48,7 @@ def test_simple_display():
"""
display("Hello, world")
container = get_display_container()
assert (
len(container.children) == 1
), "Expected one child in the display container."
assert len(container.children) == 1, "Expected one child in the display container."
assert (
container.children[0].tagName == "DIV"
), "Expected a div element in the display container."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
"""

import upytest
from pyscript import document, RUNNING_IN_WORKER

from pyscript import RUNNING_IN_WORKER, document

# In the test suite, runnint in a worker is flagged by the presence of the
# "worker" query string. We do this to avoid using RUNNING_IN_WORKER to skip
Expand Down
3 changes: 1 addition & 2 deletions 3 pyscript.core/tests/integration/python/tests/test_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
Ensure the pyscript.storage object behaves as a Python dict.
"""

from pyscript import storage, Storage

from pyscript import Storage, storage

test_store = None

Expand Down
64 changes: 17 additions & 47 deletions 64 pyscript.core/tests/integration/python/tests/test_web.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
"""

import asyncio

import upytest
from pyscript import web, when, document, RUNNING_IN_WORKER
from pyscript import RUNNING_IN_WORKER, document, web, when


def setup():
Expand Down Expand Up @@ -71,9 +72,7 @@ def test_query(self):
div.parent.id == parent_div.id
), f"The parent of the new element should be the parent div, but got {div.parent} instead of {parent_div}"
# EXPECT the new element to be an Element
assert isinstance(
div, web.Element
), "The new element should be an Element"
assert isinstance(div, web.Element), "The new element should be an Element"
# EXPECT the div attributes to be == to how they are configured in the page
assert (
div.innerHTML == "Child 1"
Expand Down Expand Up @@ -174,9 +173,7 @@ def test_inner_html_attribute(self):

# EXPECT the element html and underlying JS Element innerHTML property
# to match what we expect and what
assert (
div.innerHTML == div._dom_element.innerHTML == "<b>New Content</b>"
)
assert div.innerHTML == div._dom_element.innerHTML == "<b>New Content</b>"
assert div.textContent == div._dom_element.textContent == "New Content"

def test_text_attribute(self):
Expand All @@ -193,11 +190,7 @@ def test_text_attribute(self):
== div._dom_element.innerHTML
== "&lt;b&gt;New Content&lt;/b&gt;"
)
assert (
div.textContent
== div._dom_element.textContent
== "<b>New Content</b>"
)
assert div.textContent == div._dom_element.textContent == "<b>New Content</b>"


class TestCollection:
Expand Down Expand Up @@ -266,10 +259,7 @@ def test_create_document_element(self):
assert new_el.parent is None
web.page.body.append(new_el)

assert (
web.page.find("#new_el_id")[0].parent.tagName
== web.page.body.tagName
)
assert web.page.find("#new_el_id")[0].parent.tagName == web.page.body.tagName

def test_create_element_child(self):
selector = "#element-creation-test"
Expand Down Expand Up @@ -309,9 +299,7 @@ def test_value(self):
input_el = result[0]
assert input_el._dom_element.type == expected_type
assert (
input_el.value
== f"Content {id_}"
== input_el._dom_element.value
input_el.value == f"Content {id_}" == input_el._dom_element.value
), f"Expected '{input_el.value}' to be 'Content {id_}' to be '{input_el._dom_element.value}'"

# Check that we can set the value
Expand Down Expand Up @@ -499,11 +487,7 @@ def test_select_get_selected_option(self):
# EXPECT the selected option to be correct
assert selected_option.value == "2"
assert selected_option.innerHTML == "Option 2"
assert (
selected_option.selected
== selected_option._dom_element.selected
== True
)
assert selected_option.selected == selected_option._dom_element.selected == True


class TestElements:
Expand Down Expand Up @@ -564,9 +548,7 @@ def parse_value(v):

# Let's keep the tag in 2 variables, one for the selector and another to
# check the return tag from the selector
locator_type = el_tag = (
el_type[:-1] if el_type.endswith("_") else el_type
)
locator_type = el_tag = el_type[:-1] if el_type.endswith("_") else el_type
if additional_selector_rules:
locator_type += f"{additional_selector_rules}"

Expand All @@ -580,9 +562,7 @@ def parse_value(v):

if properties:
for k, v in properties.items():
assert v == getattr(
el, k
), f"{k} should be {v} but is {getattr(el, k)}"
assert v == getattr(el, k), f"{k} should be {v} but is {getattr(el, k)}"
return el

def test_a(self):
Expand Down Expand Up @@ -733,9 +713,7 @@ def test_form(self):
"autocomplete": "on",
"rel": "external",
}
self._create_el_and_basic_asserts(
"form", "some text", properties=properties
)
self._create_el_and_basic_asserts("form", "some text", properties=properties)

def test_h1(self):
self._create_el_and_basic_asserts("h1", "some text")
Expand Down Expand Up @@ -776,10 +754,10 @@ def test_iframe(self):
}
self._create_el_and_basic_asserts("iframe", properties=properties)

#@upytest.skip(
# @upytest.skip(
# "CHECK: This test is failing if running in a worker",
# skip_when=RUNNING_IN_WORKER,
#)
# )
def test_img(self):
properties = {
"src": "https://placehold.co/600x400",
Expand Down Expand Up @@ -855,9 +833,7 @@ def test_meter(self):
"high": 80,
"optimum": 50,
}
self._create_el_and_basic_asserts(
"meter", "some text", properties=properties
)
self._create_el_and_basic_asserts("meter", "some text", properties=properties)

def test_nav(self):
self._create_el_and_basic_asserts("nav", "some text")
Expand Down Expand Up @@ -1062,9 +1038,7 @@ def test_append_proxy_element(self):
el = result[0]
tag = el.tagName
assert tag == "DIV", tag
assert (
el.textContent == f"{div_text_content}{p_text_content}"
), el.textContent
assert el.textContent == f"{div_text_content}{p_text_content}", el.textContent
assert len(el.children) == 1, "There should be only 1 child"
assert el.children[0].tagName == "P"
assert (
Expand All @@ -1090,9 +1064,7 @@ def test_append_py_elementcollection(self):
el = result[0]
tag = el.tagName
assert tag == "DIV", tag
parent_full_content = (
f"{div_text_content}{p_text_content}{p2_text_content}"
)
parent_full_content = f"{div_text_content}{p_text_content}{p2_text_content}"
assert el.textContent == parent_full_content
assert len(el.children) == 2, "There should be only 2 children"
assert el.children[0].tagName == "P"
Expand Down Expand Up @@ -1122,9 +1094,7 @@ def test_append_js_element_nodelist(self):
el = result[0]
tag = el.tagName
assert tag == "DIV", tag
parent_full_content = (
f"{div_text_content}{p_text_content}{p2_text_content}"
)
parent_full_content = f"{div_text_content}{p_text_content}{p2_text_content}"
assert el.textContent == parent_full_content, el.innerHTML
assert len(el.children) == 2, "There should be only 2 children"
assert el.children[0].tagName == "P"
Expand Down
10 changes: 8 additions & 2 deletions 10 pyscript.core/tests/integration/python/tests/test_websocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"""

import asyncio

from pyscript import WebSocket


Expand Down Expand Up @@ -83,11 +84,16 @@ def on_close(event):
closed_flag = True
ready_to_test.set() # Finished!

ws = WebSocket(url="wss://echo.websocket.org", onopen=on_open, onmessage=on_message, onclose=on_close)
ws = WebSocket(
url="wss://echo.websocket.org",
onopen=on_open,
onmessage=on_message,
onclose=on_close,
)
# Wait for everything to be finished.
await ready_to_test.wait()
assert connected_flag is True
assert len(messages) == 2
assert "request served by" in messages[0].lower()
assert messages[1] == "Hello, world!"
assert closed_flag is True
assert closed_flag is True
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.