mirror of
https://github.com/pyscript/pyscript.git
synced 2025-12-19 18:27:29 -05:00
lint
This commit is contained in:
@@ -25,34 +25,38 @@ DEFAULT_ELEMENT_ATTRIBUTES = {
|
|||||||
"virtualkeyboardpolicy": "manual",
|
"virtualkeyboardpolicy": "manual",
|
||||||
}
|
}
|
||||||
|
|
||||||
INTERPRETERS = ['py', 'mpy']
|
INTERPRETERS = ["py", "mpy"]
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(params=INTERPRETERS)
|
@pytest.fixture(params=INTERPRETERS)
|
||||||
def interpreter(request):
|
def interpreter(request):
|
||||||
return request.param
|
return request.param
|
||||||
|
|
||||||
|
|
||||||
class TestElements(PyScriptTest):
|
class TestElements(PyScriptTest):
|
||||||
"""Test all elements in the pyweb.ui.elements module.
|
"""Test all elements in the pyweb.ui.elements module.
|
||||||
|
|
||||||
This class tests all elements in the pyweb.ui.elements module. It creates
|
This class tests all elements in the pyweb.ui.elements module. It creates
|
||||||
an element of each type, both executing in the main thread and in a worker.
|
an element of each type, both executing in the main thread and in a worker.
|
||||||
It runs each test for each interpreter defined in `INTERPRETERS`
|
It runs each test for each interpreter defined in `INTERPRETERS`
|
||||||
|
|
||||||
Each individual element test looks for the element properties, sets a value
|
Each individual element test looks for the element properties, sets a value
|
||||||
on each the supported properties and checks if the element was created correctly
|
on each the supported properties and checks if the element was created correctly
|
||||||
and all it's properties were set correctly.
|
and all it's properties were set correctly.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def _create_el_and_basic_asserts(
|
def _create_el_and_basic_asserts(
|
||||||
self,
|
self,
|
||||||
el_type,
|
el_type,
|
||||||
el_text=None,
|
el_text=None,
|
||||||
interpreter='py',
|
interpreter="py",
|
||||||
properties=None,
|
properties=None,
|
||||||
expected_errors=None,
|
expected_errors=None,
|
||||||
additional_selector_rules=None,
|
additional_selector_rules=None,
|
||||||
):
|
):
|
||||||
"""Create an element with all its properties set, by running <script type=<interpreter> ... >
|
"""Create an element with all its properties set, by running <script type=<interpreter> ... >
|
||||||
, and check if the element was created correctly and all its properties were set correctly."""
|
, and check if the element was created correctly and all its properties were set correctly.
|
||||||
|
"""
|
||||||
expected_errors = expected_errors or []
|
expected_errors = expected_errors or []
|
||||||
if not properties:
|
if not properties:
|
||||||
properties = {}
|
properties = {}
|
||||||
@@ -118,14 +122,16 @@ class TestElements(PyScriptTest):
|
|||||||
actual_val = el.evaluate(f"node => node.{k}")
|
actual_val = el.evaluate(f"node => node.{k}")
|
||||||
assert actual_val == v
|
assert actual_val == v
|
||||||
return el
|
return el
|
||||||
|
|
||||||
def test_a(self, interpreter):
|
def test_a(self, interpreter):
|
||||||
print("interpreter", interpreter)
|
print("interpreter", interpreter)
|
||||||
abbr = self._create_el_and_basic_asserts("a", "click me", interpreter)
|
abbr = self._create_el_and_basic_asserts("a", "click me", interpreter)
|
||||||
assert abbr.text_content() == "click me"
|
assert abbr.text_content() == "click me"
|
||||||
|
|
||||||
def test_abbr(self, interpreter):
|
def test_abbr(self, interpreter):
|
||||||
abbr = self._create_el_and_basic_asserts("abbr", "some text", interpreter=interpreter)
|
abbr = self._create_el_and_basic_asserts(
|
||||||
|
"abbr", "some text", interpreter=interpreter
|
||||||
|
)
|
||||||
assert abbr.text_content() == "some text"
|
assert abbr.text_content() == "some text"
|
||||||
|
|
||||||
def test_address(self, interpreter):
|
def test_address(self, interpreter):
|
||||||
@@ -141,7 +147,9 @@ class TestElements(PyScriptTest):
|
|||||||
"alt": "HTTP",
|
"alt": "HTTP",
|
||||||
}
|
}
|
||||||
# TODO: Check why click times out
|
# TODO: Check why click times out
|
||||||
self._create_el_and_basic_asserts("area", interpreter=interpreter, properties=properties)
|
self._create_el_and_basic_asserts(
|
||||||
|
"area", interpreter=interpreter, properties=properties
|
||||||
|
)
|
||||||
|
|
||||||
def test_article(self, interpreter):
|
def test_article(self, interpreter):
|
||||||
self._create_el_and_basic_asserts("article", "some text", interpreter)
|
self._create_el_and_basic_asserts("article", "some text", interpreter)
|
||||||
@@ -173,7 +181,9 @@ class TestElements(PyScriptTest):
|
|||||||
assert button.inner_html() == "click me"
|
assert button.inner_html() == "click me"
|
||||||
|
|
||||||
def test_element_button_attributes(self, interpreter):
|
def test_element_button_attributes(self, interpreter):
|
||||||
button = self._create_el_and_basic_asserts("button", "click me", interpreter, None)
|
button = self._create_el_and_basic_asserts(
|
||||||
|
"button", "click me", interpreter, None
|
||||||
|
)
|
||||||
assert button.inner_html() == "click me"
|
assert button.inner_html() == "click me"
|
||||||
|
|
||||||
def test_canvas(self, interpreter):
|
def test_canvas(self, interpreter):
|
||||||
@@ -246,7 +256,7 @@ class TestElements(PyScriptTest):
|
|||||||
"height": "200",
|
"height": "200",
|
||||||
}
|
}
|
||||||
self._create_el_and_basic_asserts(
|
self._create_el_and_basic_asserts(
|
||||||
"embed",
|
"embed",
|
||||||
interpreter=interpreter,
|
interpreter=interpreter,
|
||||||
properties=properties,
|
properties=properties,
|
||||||
expected_errors=[
|
expected_errors=[
|
||||||
@@ -276,7 +286,9 @@ class TestElements(PyScriptTest):
|
|||||||
"autocomplete": "on",
|
"autocomplete": "on",
|
||||||
"rel": "external",
|
"rel": "external",
|
||||||
}
|
}
|
||||||
self._create_el_and_basic_asserts("form", "some text", interpreter, properties=properties)
|
self._create_el_and_basic_asserts(
|
||||||
|
"form", "some text", interpreter, properties=properties
|
||||||
|
)
|
||||||
|
|
||||||
def test_h1(self, interpreter):
|
def test_h1(self, interpreter):
|
||||||
self._create_el_and_basic_asserts("h1", "some text", interpreter)
|
self._create_el_and_basic_asserts("h1", "some text", interpreter)
|
||||||
@@ -316,7 +328,8 @@ class TestElements(PyScriptTest):
|
|||||||
"height": "200",
|
"height": "200",
|
||||||
}
|
}
|
||||||
self._create_el_and_basic_asserts(
|
self._create_el_and_basic_asserts(
|
||||||
"iframe", interpreter,
|
"iframe",
|
||||||
|
interpreter,
|
||||||
properties=properties,
|
properties=properties,
|
||||||
expected_errors=[
|
expected_errors=[
|
||||||
"Failed to load resource: the server responded with a status of 404 (File not found)"
|
"Failed to load resource: the server responded with a status of 404 (File not found)"
|
||||||
@@ -351,7 +364,9 @@ class TestElements(PyScriptTest):
|
|||||||
"required": True,
|
"required": True,
|
||||||
"size": 20,
|
"size": 20,
|
||||||
}
|
}
|
||||||
self._create_el_and_basic_asserts("input_", interpreter=interpreter, properties=properties)
|
self._create_el_and_basic_asserts(
|
||||||
|
"input_", interpreter=interpreter, properties=properties
|
||||||
|
)
|
||||||
|
|
||||||
def test_ins(self, interpreter):
|
def test_ins(self, interpreter):
|
||||||
self._create_el_and_basic_asserts(
|
self._create_el_and_basic_asserts(
|
||||||
@@ -409,7 +424,9 @@ class TestElements(PyScriptTest):
|
|||||||
"high": 80,
|
"high": 80,
|
||||||
"optimum": 50,
|
"optimum": 50,
|
||||||
}
|
}
|
||||||
self._create_el_and_basic_asserts("meter", "some text", interpreter, properties=properties)
|
self._create_el_and_basic_asserts(
|
||||||
|
"meter", "some text", interpreter, properties=properties
|
||||||
|
)
|
||||||
|
|
||||||
def test_nav(self, interpreter):
|
def test_nav(self, interpreter):
|
||||||
self._create_el_and_basic_asserts("nav", "some text", interpreter)
|
self._create_el_and_basic_asserts("nav", "some text", interpreter)
|
||||||
@@ -504,7 +521,7 @@ class TestElements(PyScriptTest):
|
|||||||
def test_style(self, interpreter):
|
def test_style(self, interpreter):
|
||||||
self._create_el_and_basic_asserts(
|
self._create_el_and_basic_asserts(
|
||||||
"style",
|
"style",
|
||||||
"body {background-color: red;}",
|
"body {background-color: red;}",
|
||||||
interpreter,
|
interpreter,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user