hyperscript
Advanced tools
| import unittest | ||
| from hyperscript import h | ||
| class TestElement(unittest.TestCase): | ||
| def test_element(self): | ||
| self.assertEqual(str(h("div")), "<div></div>") | ||
| def test_nested(self): | ||
| self.assertEqual( | ||
| str(h("div", h("h1", "Header"), h("p", "Paragraph"))), | ||
| "<div><h1>Header</h1><p>Paragraph</p></div>", | ||
| ) | ||
| def test_nested_arrays(self): | ||
| self.assertEqual( | ||
| str(h("div", [h("h1", "Header"), h("p", "Paragraph")])), | ||
| "<div><h1>Header</h1><p>Paragraph</p></div>", | ||
| ) | ||
| def test_namespace(self): | ||
| self.assertEqual(str(h("myns:mytag")), "<myns:mytag></myns:mytag>") | ||
| def test_id_selector(self): | ||
| self.assertEqual(str(h("div#foo")), '<div id="foo"></div>') | ||
| def test_class_selector(self): | ||
| self.assertEqual(str(h("div.foo")), '<div class="foo"></div>') | ||
| self.assertEqual(str(h("div.foo.bar")), '<div class="foo bar"></div>') | ||
| def test_properties(self): | ||
| self.assertEqual( | ||
| str(h("a", {"href": "https://example.com/"})), | ||
| '<a href="https://example.com/"></a>', | ||
| ) | ||
| self.assertEqual(str(h("div.foo.bar")), '<div class="foo bar"></div>') | ||
| self.assertEqual(str(h("div", {"prop": "foo"})), '<div prop="foo"></div>') | ||
| self.assertEqual( | ||
| str(h("button", {"disabled": None})), "<button disabled></button>" | ||
| ) | ||
| self.assertEqual( | ||
| str(h("button", {"disabled": True})), "<button disabled></button>" | ||
| ) | ||
| self.assertEqual( | ||
| str(h("button", {"disabled": ""})), '<button disabled=""></button>' | ||
| ) | ||
| def test_styles(self): | ||
| self.assertEqual( | ||
| str(h("div", {"style": {"color": "red"}})), '<div style="color: red"></div>' | ||
| ) | ||
| def test_str_styles(self): | ||
| self.assertEqual( | ||
| str(h("div", {"style": "color: red"})), '<div style="color: red"></div>' | ||
| ) | ||
| def test_other_types(self): | ||
| self.assertEqual(str(h("div", True, 5, None)), "<div>True5None</div>") | ||
| def test_void(self): | ||
| self.assertEqual(str(h("br")), "<br>") | ||
| with self.assertRaises(ValueError): | ||
| h("br", "foo") | ||
| def test_equality(self): | ||
| self.assertEqual(h("div"), h("div")) | ||
| self.assertEqual(h("div", h("p", "Foo")), h("div", h("p", "Foo"))) | ||
| self.assertEqual(h("div", h("p", "Foo")), "<div><p>Foo</p></div>") | ||
| self.assertNotEqual(h("div"), h("p")) | ||
| self.assertNotEqual(h("div", h("p", "Foo")), h("div", h("p", "Bar"))) |
| Metadata-Version: 2.1 | ||
| Name: hyperscript | ||
| Version: 0.0.1 | ||
| Version: 0.0.2 | ||
| Summary: HyperText with Python | ||
@@ -16,4 +16,6 @@ Author-email: Vincent Chan <vincent@qualdata.io> | ||
| Description-Content-Type: text/markdown | ||
| License-File: LICENSE | ||
| Provides-Extra: lint | ||
| License-File: LICENSE | ||
| Requires-Dist: black; extra == "lint" | ||
| Requires-Dist: pylint; extra == "lint" | ||
@@ -20,0 +22,0 @@ # Hyperscript |
@@ -10,2 +10,3 @@ LICENSE | ||
| hyperscript.egg-info/requires.txt | ||
| hyperscript.egg-info/top_level.txt | ||
| hyperscript.egg-info/top_level.txt | ||
| tests/test_element.py |
| from hyperscript.element import Element | ||
| __version__ = "0.0.1" | ||
| __version__ = "0.0.2" | ||
@@ -5,0 +5,0 @@ |
@@ -91,1 +91,8 @@ import re | ||
| return f"<{opening_tag}>{children}</{self.tag}>" | ||
| def __eq__(self, other) -> bool: | ||
| if isinstance(other, Element): | ||
| return str(self) == str(other) | ||
| if isinstance(other, str): | ||
| return str(self) == other | ||
| return False |
+4
-2
| Metadata-Version: 2.1 | ||
| Name: hyperscript | ||
| Version: 0.0.1 | ||
| Version: 0.0.2 | ||
| Summary: HyperText with Python | ||
@@ -16,4 +16,6 @@ Author-email: Vincent Chan <vincent@qualdata.io> | ||
| Description-Content-Type: text/markdown | ||
| License-File: LICENSE | ||
| Provides-Extra: lint | ||
| License-File: LICENSE | ||
| Requires-Dist: black; extra == "lint" | ||
| Requires-Dist: pylint; extra == "lint" | ||
@@ -20,0 +22,0 @@ # Hyperscript |
Alert delta unavailable
Currently unable to show alert delta for PyPI packages.
11602
33.99%13
8.33%149
75.29%