diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 020a43f..aaaa2a4 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -53,7 +53,7 @@ repos: entry: pyupgrade language: system types: [python] - args: [--py37-plus] + args: [--py310-plus] - id: trailing-whitespace name: Trim Trailing Whitespace entry: trailing-whitespace-fixer diff --git a/CONTRIBUTING.MD b/CONTRIBUTING.MD index 9cac9f1..8bc2a21 100644 --- a/CONTRIBUTING.MD +++ b/CONTRIBUTING.MD @@ -31,9 +31,9 @@ We try not to have strong boundaries in what kinds of contributions are accepted - Adding meta-data - adding tags to your example will help us organize this repository in a much more meaningful way. Example tags come at the beginning of your main `HTML` file in the form of a comment. - - you're also welcome to add your email or name or other forms of contact information in the header at the beginning of the file. + - you're also welcome to add your email or name or other forms of contact information in the header at the beginning of the file. For reference see the [example](examples/hello_world.html). -TODO Add back in `See the example examples/hello_world.html` +TODO Add back in `See the example examples/hello_world.html` - Adding docs @@ -54,7 +54,7 @@ The PyScript Collective also welcomes contributions like blog posts, videos, vid The contributions in this topic are more similar to what an `awesome-page` would look like. -*If you want to add a new kind of contribution that wasn't laid out on the [README](index) yet, feel free to do so.* +_If you want to add a new kind of contribution that wasn't laid out on the [README](index) yet, feel free to do so._ #### Recommended guidelines for a resource diff --git a/environment.yml b/environment.yml index 4e4bb33..0e1e2fc 100644 --- a/environment.yml +++ b/environment.yml @@ -3,7 +3,7 @@ channels: - conda-forge - microsoft dependencies: -- python=3.9 +- python=3.10 - pip=20.2.2 - pytest=7 - nodejs=16 diff --git a/poetry.lock b/poetry.lock index 1f5ad85..5af12f7 100644 --- a/poetry.lock +++ b/poetry.lock @@ -76,11 +76,11 @@ lxml = ["lxml"] [[package]] name = "black" -version = "22.8.0" +version = "22.10.0" description = "The uncompromising code formatter." category = "dev" optional = false -python-versions = ">=3.6.2" +python-versions = ">=3.7" [package.dependencies] click = ">=8.0.0" @@ -338,7 +338,7 @@ lxml = ["lxml"] [[package]] name = "identify" -version = "2.5.5" +version = "2.5.6" description = "File identification library for Python" category = "dev" optional = false @@ -608,7 +608,7 @@ test = ["appdirs (==1.4.4)", "pytest (>=6)", "pytest-cov (>=2.7)", "pytest-mock [[package]] name = "playwright" -version = "1.26.1" +version = "1.27.1" description = "A high-level API to automate web browsers" category = "dev" optional = false @@ -617,7 +617,6 @@ python-versions = ">=3.7" [package.dependencies] greenlet = "1.1.3" pyee = "8.1.0" -websockets = "10.1" [[package]] name = "pluggy" @@ -812,7 +811,7 @@ unidecode = ["Unidecode (>=1.1.1)"] [[package]] name = "pytz" -version = "2022.2.1" +version = "2022.5" description = "World timezone definitions, modern and historical" category = "dev" optional = false @@ -820,7 +819,7 @@ python-versions = "*" [[package]] name = "pyupgrade" -version = "2.38.2" +version = "3.1.0" description = "A tool to automatically upgrade syntax for newer versions." category = "dev" optional = false @@ -868,7 +867,7 @@ docutils = ">=0.11,<1.0" [[package]] name = "rich" -version = "12.5.1" +version = "12.6.0" description = "Render rich text, tables, progress bars, syntax highlighting, markdown and more to the terminal" category = "main" optional = false @@ -937,6 +936,10 @@ docs = ["furo", "jaraco.packaging (>=9)", "jaraco.tidelift (>=1.4)", "pygments-g testing = ["build[virtualenv]", "filelock (>=3.4.0)", "flake8 (<5)", "flake8-2020", "ini2toml[lite] (>=0.9)", "jaraco.envs (>=2.2)", "jaraco.path (>=3.2.0)", "pip (>=19.1)", "pip-run (>=8.8)", "pytest (>=6)", "pytest-black (>=0.3.7)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=1.3)", "pytest-flake8", "pytest-mypy (>=0.9.1)", "pytest-perf", "pytest-timeout", "pytest-xdist", "tomli-w (>=1.0.0)", "virtualenv (>=13.0.0)", "wheel"] testing-integration = ["build[virtualenv]", "filelock (>=3.4.0)", "jaraco.envs (>=2.2)", "jaraco.path (>=3.2.0)", "pytest", "pytest-enabler", "pytest-xdist", "tomli", "virtualenv (>=13.0.0)", "wheel"] +[package.extras] +github = ["pygithub (>=1.43.3)", "jinja2 (>=3.1.0)"] +gitlab = ["python-gitlab (>=1.3.0)"] + [[package]] name = "shellingham" version = "1.5.0" @@ -1146,11 +1149,11 @@ python-versions = "*" [[package]] name = "tokenize-rt" -version = "4.2.1" +version = "5.0.0" description = "A wrapper around the stdlib `tokenize` which roundtrips." category = "dev" optional = false -python-versions = ">=3.6.1" +python-versions = ">=3.7" [[package]] name = "toml" @@ -1237,7 +1240,7 @@ types-urllib3 = "<1.27" [[package]] name = "types-urllib3" -version = "1.26.25" +version = "1.26.25.1" description = "Typing stubs for urllib3" category = "dev" optional = false @@ -1245,7 +1248,7 @@ python-versions = "*" [[package]] name = "typing-extensions" -version = "4.3.0" +version = "4.4.0" description = "Backported and Experimental Type Hints for Python 3.7+" category = "dev" optional = false @@ -1304,14 +1307,6 @@ category = "dev" optional = false python-versions = "*" -[[package]] -name = "websockets" -version = "10.1" -description = "An implementation of the WebSocket Protocol (RFC 6455 & 7692)" -category = "dev" -optional = false -python-versions = ">=3.7" - [[package]] name = "xdoctest" version = "1.1.0" @@ -1339,7 +1334,7 @@ tests-strict = ["cmake (==3.21.2)", "codecov (==2.0.15)", "ninja (==1.10.2)", "p [metadata] lock-version = "1.1" python-versions = "^3.10" -content-hash = "792df2bb736dd532bf9aadb0cf167c47f4a8ea832ea11f0c127f8593e888fcf8" +content-hash = "62c24bf18d40370799e3dd94b3875eeabe1855e53bfe3c6e602618e9478e6f16" [metadata.files] alabaster = [ @@ -1367,29 +1362,27 @@ beautifulsoup4 = [ {file = "beautifulsoup4-4.11.1.tar.gz", hash = "sha256:ad9aa55b65ef2808eb405f46cf74df7fcb7044d5cbc26487f96eb2ef2e436693"}, ] black = [ - {file = "black-22.8.0-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:ce957f1d6b78a8a231b18e0dd2d94a33d2ba738cd88a7fe64f53f659eea49fdd"}, - {file = "black-22.8.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:5107ea36b2b61917956d018bd25129baf9ad1125e39324a9b18248d362156a27"}, - {file = "black-22.8.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:e8166b7bfe5dcb56d325385bd1d1e0f635f24aae14b3ae437102dedc0c186747"}, - {file = "black-22.8.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:dd82842bb272297503cbec1a2600b6bfb338dae017186f8f215c8958f8acf869"}, - {file = "black-22.8.0-cp310-cp310-win_amd64.whl", hash = "sha256:d839150f61d09e7217f52917259831fe2b689f5c8e5e32611736351b89bb2a90"}, - {file = "black-22.8.0-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:a05da0430bd5ced89176db098567973be52ce175a55677436a271102d7eaa3fe"}, - {file = "black-22.8.0-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:4a098a69a02596e1f2a58a2a1c8d5a05d5a74461af552b371e82f9fa4ada8342"}, - {file = "black-22.8.0-cp36-cp36m-win_amd64.whl", hash = "sha256:5594efbdc35426e35a7defa1ea1a1cb97c7dbd34c0e49af7fb593a36bd45edab"}, - {file = "black-22.8.0-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:a983526af1bea1e4cf6768e649990f28ee4f4137266921c2c3cee8116ae42ec3"}, - {file = "black-22.8.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:3b2c25f8dea5e8444bdc6788a2f543e1fb01494e144480bc17f806178378005e"}, - {file = "black-22.8.0-cp37-cp37m-win_amd64.whl", hash = "sha256:78dd85caaab7c3153054756b9fe8c611efa63d9e7aecfa33e533060cb14b6d16"}, - {file = "black-22.8.0-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:cea1b2542d4e2c02c332e83150e41e3ca80dc0fb8de20df3c5e98e242156222c"}, - {file = "black-22.8.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:5b879eb439094751185d1cfdca43023bc6786bd3c60372462b6f051efa6281a5"}, - {file = "black-22.8.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:0a12e4e1353819af41df998b02c6742643cfef58282915f781d0e4dd7a200411"}, - {file = "black-22.8.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c3a73f66b6d5ba7288cd5d6dad9b4c9b43f4e8a4b789a94bf5abfb878c663eb3"}, - {file = "black-22.8.0-cp38-cp38-win_amd64.whl", hash = "sha256:e981e20ec152dfb3e77418fb616077937378b322d7b26aa1ff87717fb18b4875"}, - {file = "black-22.8.0-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:8ce13ffed7e66dda0da3e0b2eb1bdfc83f5812f66e09aca2b0978593ed636b6c"}, - {file = "black-22.8.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:32a4b17f644fc288c6ee2bafdf5e3b045f4eff84693ac069d87b1a347d861497"}, - {file = "black-22.8.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:0ad827325a3a634bae88ae7747db1a395d5ee02cf05d9aa7a9bd77dfb10e940c"}, - {file = "black-22.8.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:53198e28a1fb865e9fe97f88220da2e44df6da82b18833b588b1883b16bb5d41"}, - {file = "black-22.8.0-cp39-cp39-win_amd64.whl", hash = "sha256:bc4d4123830a2d190e9cc42a2e43570f82ace35c3aeb26a512a2102bce5af7ec"}, - {file = "black-22.8.0-py3-none-any.whl", hash = "sha256:d2c21d439b2baf7aa80d6dd4e3659259be64c6f49dfd0f32091063db0e006db4"}, - {file = "black-22.8.0.tar.gz", hash = "sha256:792f7eb540ba9a17e8656538701d3eb1afcb134e3b45b71f20b25c77a8db7e6e"}, + {file = "black-22.10.0-1fixedarch-cp310-cp310-macosx_11_0_x86_64.whl", hash = "sha256:5cc42ca67989e9c3cf859e84c2bf014f6633db63d1cbdf8fdb666dcd9e77e3fa"}, + {file = "black-22.10.0-1fixedarch-cp311-cp311-macosx_11_0_x86_64.whl", hash = "sha256:5d8f74030e67087b219b032aa33a919fae8806d49c867846bfacde57f43972ef"}, + {file = "black-22.10.0-1fixedarch-cp37-cp37m-macosx_10_16_x86_64.whl", hash = "sha256:197df8509263b0b8614e1df1756b1dd41be6738eed2ba9e9769f3880c2b9d7b6"}, + {file = "black-22.10.0-1fixedarch-cp38-cp38-macosx_10_16_x86_64.whl", hash = "sha256:2644b5d63633702bc2c5f3754b1b475378fbbfb481f62319388235d0cd104c2d"}, + {file = "black-22.10.0-1fixedarch-cp39-cp39-macosx_11_0_x86_64.whl", hash = "sha256:e41a86c6c650bcecc6633ee3180d80a025db041a8e2398dcc059b3afa8382cd4"}, + {file = "black-22.10.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:2039230db3c6c639bd84efe3292ec7b06e9214a2992cd9beb293d639c6402edb"}, + {file = "black-22.10.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:14ff67aec0a47c424bc99b71005202045dc09270da44a27848d534600ac64fc7"}, + {file = "black-22.10.0-cp310-cp310-win_amd64.whl", hash = "sha256:819dc789f4498ecc91438a7de64427c73b45035e2e3680c92e18795a839ebb66"}, + {file = "black-22.10.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:5b9b29da4f564ba8787c119f37d174f2b69cdfdf9015b7d8c5c16121ddc054ae"}, + {file = "black-22.10.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b8b49776299fece66bffaafe357d929ca9451450f5466e997a7285ab0fe28e3b"}, + {file = "black-22.10.0-cp311-cp311-win_amd64.whl", hash = "sha256:21199526696b8f09c3997e2b4db8d0b108d801a348414264d2eb8eb2532e540d"}, + {file = "black-22.10.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:1e464456d24e23d11fced2bc8c47ef66d471f845c7b7a42f3bd77bf3d1789650"}, + {file = "black-22.10.0-cp37-cp37m-win_amd64.whl", hash = "sha256:9311e99228ae10023300ecac05be5a296f60d2fd10fff31cf5c1fa4ca4b1988d"}, + {file = "black-22.10.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:fba8a281e570adafb79f7755ac8721b6cf1bbf691186a287e990c7929c7692ff"}, + {file = "black-22.10.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:915ace4ff03fdfff953962fa672d44be269deb2eaf88499a0f8805221bc68c87"}, + {file = "black-22.10.0-cp38-cp38-win_amd64.whl", hash = "sha256:444ebfb4e441254e87bad00c661fe32df9969b2bf224373a448d8aca2132b395"}, + {file = "black-22.10.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:974308c58d057a651d182208a484ce80a26dac0caef2895836a92dd6ebd725e0"}, + {file = "black-22.10.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:72ef3925f30e12a184889aac03d77d031056860ccae8a1e519f6cbb742736383"}, + {file = "black-22.10.0-cp39-cp39-win_amd64.whl", hash = "sha256:432247333090c8c5366e69627ccb363bc58514ae3e63f7fc75c54b1ea80fa7de"}, + {file = "black-22.10.0-py3-none-any.whl", hash = "sha256:c957b2b4ea88587b46cf49d1dc17681c1e672864fd7af32fc1e9664d572b3458"}, + {file = "black-22.10.0.tar.gz", hash = "sha256:f513588da599943e0cde4e32cc9879e825d58720d6557062d1098c5ad80080e1"}, ] certifi = [ {file = "certifi-2022.9.24-py3-none-any.whl", hash = "sha256:90c1a32f1d68f940488354e36370f6cca89f0f106db09518524c88d6ed83f382"}, @@ -1576,8 +1569,8 @@ html5lib = [ {file = "html5lib-1.1.tar.gz", hash = "sha256:b2e5b40261e20f354d198eae92afc10d750afb487ed5e50f9c4eaf07c184146f"}, ] identify = [ - {file = "identify-2.5.5-py2.py3-none-any.whl", hash = "sha256:ef78c0d96098a3b5fe7720be4a97e73f439af7cf088ebf47b620aeaa10fadf97"}, - {file = "identify-2.5.5.tar.gz", hash = "sha256:322a5699daecf7c6fd60e68852f36f2ecbb6a36ff6e6e973e0d2bb6fca203ee6"}, + {file = "identify-2.5.6-py2.py3-none-any.whl", hash = "sha256:b276db7ec52d7e89f5bc4653380e33054ddc803d25875952ad90b0f012cbcdaa"}, + {file = "identify-2.5.6.tar.gz", hash = "sha256:6c32dbd747aa4ceee1df33f25fed0b0f6e0d65721b15bd151307ff7056d50245"}, ] idna = [ {file = "idna-3.4-py3-none-any.whl", hash = "sha256:90b77e79eaa3eba6de819a0c442c0b4ceefc341a7a2ab77d7562bf49f425c5c2"}, @@ -1691,7 +1684,6 @@ mypy = [ {file = "mypy-0.991-cp39-cp39-win_amd64.whl", hash = "sha256:74e259b5c19f70d35fcc1ad3d56499065c601dfe94ff67ae48b85596b9ec1461"}, {file = "mypy-0.991-py3-none-any.whl", hash = "sha256:de32edc9b0a7e67c2775e574cb061a537660e51210fbf6006b0b36ea695ae9bb"}, {file = "mypy-0.991.tar.gz", hash = "sha256:3c0165ba8f354a6d9881809ef29f1a9318a236a6d81c690094c5df32107bde06"}, -] mypy-extensions = [ {file = "mypy_extensions-0.4.3-py2.py3-none-any.whl", hash = "sha256:090fedd75945a69ae91ce1303b5824f428daf5a028d2f6ab8a299250a846f15d"}, {file = "mypy_extensions-0.4.3.tar.gz", hash = "sha256:2d82818f5bb3e369420cb3c4060a7970edba416647068eb4c5343488a6c604a8"}, @@ -1729,13 +1721,13 @@ platformdirs = [ {file = "platformdirs-2.5.2.tar.gz", hash = "sha256:58c8abb07dcb441e6ee4b11d8df0ac856038f944ab98b7be6b27b2a3c7feef19"}, ] playwright = [ - {file = "playwright-1.26.1-py3-none-macosx_10_13_x86_64.whl", hash = "sha256:eabf81e932076be5afe8f198c13cde913db319ccb07a9c16ea13bd0d372b40b2"}, - {file = "playwright-1.26.1-py3-none-macosx_11_0_arm64.whl", hash = "sha256:ecd2d47a671d40f2c9f2fa70dec5c4e8f341194e7450e1483c787e02eecb6f61"}, - {file = "playwright-1.26.1-py3-none-macosx_11_0_universal2.whl", hash = "sha256:a04bb9f2b25ad00077c7816e51b2cc3edc9b5ae7ed864ab1efbc3037a16db868"}, - {file = "playwright-1.26.1-py3-none-manylinux1_x86_64.whl", hash = "sha256:c3cc87fc738d7c7668d8e3a8086fca2c6f981d31e560cee5f89415d17160f7e5"}, - {file = "playwright-1.26.1-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:e8b3a58cd903d21bf71b0361b8f1379bb9de8046ecf5a866f5d13bd815100099"}, - {file = "playwright-1.26.1-py3-none-win32.whl", hash = "sha256:1b06a0cd1d0c4ded1c5412129f9207d2589aa5ac86645cfa1a89690ef610228b"}, - {file = "playwright-1.26.1-py3-none-win_amd64.whl", hash = "sha256:9dfbb664a0d3865ec3db4cd636dab755c7bf5eeadcaf1d6abe9ab8c9c26c431f"}, + {file = "playwright-1.27.1-py3-none-macosx_10_13_x86_64.whl", hash = "sha256:3b584bc23bfacfbfb91777663d2b68891d8a16c5c2228b4702c6a7d29c0ac364"}, + {file = "playwright-1.27.1-py3-none-macosx_11_0_arm64.whl", hash = "sha256:771d690aaa933bb40f60abbe7935979cfa9a5bec498bbc57cd87baf038348d2b"}, + {file = "playwright-1.27.1-py3-none-macosx_11_0_universal2.whl", hash = "sha256:db89faac3c535e289f8463b184ffd4523d97b5e959d97bae330d29522c5bfb9d"}, + {file = "playwright-1.27.1-py3-none-manylinux1_x86_64.whl", hash = "sha256:5e7be8dc52b9e3340a08fd15b7d3cdd635efd51c0c62bd1edba55f0bfeea293c"}, + {file = "playwright-1.27.1-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c32bfbbb6e6529f7f7176551eda7061e9f205e19259052ef663dcae7109c1f12"}, + {file = "playwright-1.27.1-py3-none-win32.whl", hash = "sha256:464f3a0ea48aeb42adbdada88a91fd36d4311ae7020d2ab58f410c4c92e0ddfe"}, + {file = "playwright-1.27.1-py3-none-win_amd64.whl", hash = "sha256:fc8ce323cf116e27902f327cee1cba6fc0c5400e9281df8e53d3355de88336ba"}, ] pluggy = [ {file = "pluggy-1.0.0-py2.py3-none-any.whl", hash = "sha256:74134bbf457f031a36d68416e1509f34bd5ccc019f0bcc952c7b909d06b37bd3"}, @@ -1802,12 +1794,12 @@ python-slugify = [ {file = "python_slugify-6.1.2-py2.py3-none-any.whl", hash = "sha256:7b2c274c308b62f4269a9ba701aa69a797e9bca41aeee5b3a9e79e36b6656927"}, ] pytz = [ - {file = "pytz-2022.2.1-py2.py3-none-any.whl", hash = "sha256:220f481bdafa09c3955dfbdddb7b57780e9a94f5127e35456a48589b9e0c0197"}, - {file = "pytz-2022.2.1.tar.gz", hash = "sha256:cea221417204f2d1a2aa03ddae3e867921971d0d76f14d87abb4414415bbdcf5"}, + {file = "pytz-2022.5-py2.py3-none-any.whl", hash = "sha256:335ab46900b1465e714b4fda4963d87363264eb662aab5e65da039c25f1f5b22"}, + {file = "pytz-2022.5.tar.gz", hash = "sha256:c4d88f472f54d615e9cd582a5004d1e5f624854a6a27a6211591c251f22a6914"}, ] pyupgrade = [ - {file = "pyupgrade-2.38.2-py2.py3-none-any.whl", hash = "sha256:41bb9a9fd48fe57163b0dacffff433d6d5a63a0f7c2402918917b5f1a533342b"}, - {file = "pyupgrade-2.38.2.tar.gz", hash = "sha256:a5d778c9de0b53975c6a9eac2d0df5adfad244a9f7d7993d8a114223ebbda367"}, + {file = "pyupgrade-3.1.0-py2.py3-none-any.whl", hash = "sha256:77c6101a710be3e24804891e43388cedbee617258e93b09c8c5e58de08617758"}, + {file = "pyupgrade-3.1.0.tar.gz", hash = "sha256:7a8d393d85e15e0e2753e90b7b2e173b9d29dfd71e61f93d93e985b242627ed3"}, ] pyyaml = [ {file = "PyYAML-6.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:d4db7c7aef085872ef65a8fd7d6d09a14ae91f691dec3e87ee5ee0539d516f53"}, @@ -1859,8 +1851,8 @@ restructuredtext-lint = [ {file = "restructuredtext_lint-1.4.0.tar.gz", hash = "sha256:1b235c0c922341ab6c530390892eb9e92f90b9b75046063e047cacfb0f050c45"}, ] rich = [ - {file = "rich-12.5.1-py3-none-any.whl", hash = "sha256:2eb4e6894cde1e017976d2975ac210ef515d7548bc595ba20e195fb9628acdeb"}, - {file = "rich-12.5.1.tar.gz", hash = "sha256:63a5c5ce3673d3d5fbbf23cd87e11ab84b6b451436f1b7f19ec54b6bc36ed7ca"}, + {file = "rich-12.6.0-py3-none-any.whl", hash = "sha256:a4eb26484f2c82589bd9a17c73d32a010b1e29d89f1604cd9bf3a2097b81bb5e"}, + {file = "rich-12.6.0.tar.gz", hash = "sha256:ba3a3775974105c221d31141f2c116f4fd65c5ceb0698657a11e9f295ec93fd0"}, ] "ruamel.yaml" = [ {file = "ruamel.yaml-0.17.21-py3-none-any.whl", hash = "sha256:742b35d3d665023981bd6d16b3d24248ce5df75fdb4e2924e93a05c1f8b61ca7"}, @@ -1902,10 +1894,6 @@ safety = [ {file = "safety-2.3.1-py3-none-any.whl", hash = "sha256:8f098d12b607db2756886280e85c28ece8db1bba4f45fc5f981f4663217bd619"}, {file = "safety-2.3.1.tar.gz", hash = "sha256:6e6fcb7d4e8321098cf289f59b65051cafd3467f089c6e57c9f894ae32c23b71"}, ] -setuptools = [ - {file = "setuptools-65.5.1-py3-none-any.whl", hash = "sha256:d0b9a8433464d5800cbe05094acf5c6d52a91bfac9b52bcfc4d41382be5d5d31"}, - {file = "setuptools-65.5.1.tar.gz", hash = "sha256:e197a19aa8ec9722928f2206f8de752def0e4c9fc6953527360d1c36d94ddb2f"}, -] shellingham = [ {file = "shellingham-1.5.0-py2.py3-none-any.whl", hash = "sha256:a8f02ba61b69baaa13facdba62908ca8690a94b8119b69f5ec5873ea85f7391b"}, {file = "shellingham-1.5.0.tar.gz", hash = "sha256:72fb7f5c63103ca2cb91b23dee0c71fe8ad6fbfd46418ef17dbe40db51592dad"}, @@ -1975,8 +1963,8 @@ text-unidecode = [ {file = "text_unidecode-1.3-py2.py3-none-any.whl", hash = "sha256:1311f10e8b895935241623731c2ba64f4c455287888b18189350b67134a822e8"}, ] tokenize-rt = [ - {file = "tokenize_rt-4.2.1-py2.py3-none-any.whl", hash = "sha256:08a27fa032a81cf45e8858d0ac706004fcd523e8463415ddf1442be38e204ea8"}, - {file = "tokenize_rt-4.2.1.tar.gz", hash = "sha256:0d4f69026fed520f8a1e0103aa36c406ef4661417f20ca643f913e33531b3b94"}, + {file = "tokenize_rt-5.0.0-py2.py3-none-any.whl", hash = "sha256:c67772c662c6b3dc65edf66808577968fb10badfc2042e3027196bed4daf9e5a"}, + {file = "tokenize_rt-5.0.0.tar.gz", hash = "sha256:3160bc0c3e8491312d0485171dea861fc160a240f5f5766b72a1165408d10740"}, ] toml = [ {file = "toml-0.10.2-py2.py3-none-any.whl", hash = "sha256:806143ae5bfb6a3c6e736a764057db0e6a0e05e338b5630894a5f779cabb4f9b"}, @@ -2020,12 +2008,12 @@ types-requests = [ {file = "types_requests-2.28.11.5-py3-none-any.whl", hash = "sha256:091d4a5a33c1b4f20d8b1b952aa8fa27a6e767c44c3cf65e56580df0b05fd8a9"}, ] types-urllib3 = [ - {file = "types-urllib3-1.26.25.tar.gz", hash = "sha256:5aef0e663724eef924afa8b320b62ffef2c1736c1fa6caecfc9bc6c8ae2c3def"}, - {file = "types_urllib3-1.26.25-py3-none-any.whl", hash = "sha256:c1d78cef7bd581e162e46c20a57b2e1aa6ebecdcf01fd0713bb90978ff3e3427"}, + {file = "types-urllib3-1.26.25.1.tar.gz", hash = "sha256:a948584944b2412c9a74b9cf64f6c48caf8652cb88b38361316f6d15d8a184cd"}, + {file = "types_urllib3-1.26.25.1-py3-none-any.whl", hash = "sha256:f6422596cc9ee5fdf68f9d547f541096a20c2dcfd587e37c804c9ea720bf5cb2"}, ] typing-extensions = [ - {file = "typing_extensions-4.3.0-py3-none-any.whl", hash = "sha256:25642c956049920a5aa49edcdd6ab1e06d7e5d467fc00e0506c44ac86fbfca02"}, - {file = "typing_extensions-4.3.0.tar.gz", hash = "sha256:e6d2677a32f47fc7eb2795db1dd15c1f34eff616bcaf2cfb5e997f854fa1c4a6"}, + {file = "typing_extensions-4.4.0-py3-none-any.whl", hash = "sha256:16fa4864408f655d35ec496218b85f79b3437c829e93320c7c9215ccfd92489e"}, + {file = "typing_extensions-4.4.0.tar.gz", hash = "sha256:1511434bb92bf8dd198c12b1cc812e800d4181cfcb867674e0f8279cc93087aa"}, ] urllib3 = [ {file = "urllib3-1.26.12-py2.py3-none-any.whl", hash = "sha256:b930dd878d5a8afb066a637fbb35144fe7901e3b209d1cd4f524bd0e9deee997"}, @@ -2043,56 +2031,6 @@ webencodings = [ {file = "webencodings-0.5.1-py2.py3-none-any.whl", hash = "sha256:a0af1213f3c2226497a97e2b3aa01a7e4bee4f403f95be16fc9acd2947514a78"}, {file = "webencodings-0.5.1.tar.gz", hash = "sha256:b36a1c245f2d304965eb4e0a82848379241dc04b865afcc4aab16748587e1923"}, ] -websockets = [ - {file = "websockets-10.1-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:38db6e2163b021642d0a43200ee2dec8f4980bdbda96db54fde72b283b54cbfc"}, - {file = "websockets-10.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:e1b60fd297adb9fc78375778a5220da7f07bf54d2a33ac781319650413fc6a60"}, - {file = "websockets-10.1-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:3477146d1f87ead8df0f27e8960249f5248dceb7c2741e8bbec9aa5338d0c053"}, - {file = "websockets-10.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:bb01ea7b5f52e7125bdc3c5807aeaa2d08a0553979cf2d96a8b7803ea33e15e7"}, - {file = "websockets-10.1-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:9fd62c6dc83d5d35fb6a84ff82ec69df8f4657fff05f9cd6c7d9bec0dd57f0f6"}, - {file = "websockets-10.1-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:3bbf080f3892ba1dc8838786ec02899516a9d227abe14a80ef6fd17d4fb57127"}, - {file = "websockets-10.1-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:5560558b0dace8312c46aa8915da977db02738ac8ecffbc61acfbfe103e10155"}, - {file = "websockets-10.1-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:667c41351a6d8a34b53857ceb8343a45c85d438ee4fd835c279591db8aeb85be"}, - {file = "websockets-10.1-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:468f0031fdbf4d643f89403a66383247eb82803430b14fa27ce2d44d2662ca37"}, - {file = "websockets-10.1-cp310-cp310-win32.whl", hash = "sha256:d0d81b46a5c87d443e40ce2272436da8e6092aa91f5fbeb60d1be9f11eff5b4c"}, - {file = "websockets-10.1-cp310-cp310-win_amd64.whl", hash = "sha256:b68b6caecb9a0c6db537aa79750d1b592a841e4f1a380c6196091e65b2ad35f9"}, - {file = "websockets-10.1-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:a249139abc62ef333e9e85064c27fefb113b16ffc5686cefc315bdaef3eefbc8"}, - {file = "websockets-10.1-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:8877861e3dee38c8d302eee0d5dbefa6663de3b46dc6a888f70cd7e82562d1f7"}, - {file = "websockets-10.1-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:e3872ae57acd4306ecf937d36177854e218e999af410a05c17168cd99676c512"}, - {file = "websockets-10.1-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:b66e6d514f12c28d7a2d80bb2a48ef223342e99c449782d9831b0d29a9e88a17"}, - {file = "websockets-10.1-cp37-cp37m-musllinux_1_1_aarch64.whl", hash = "sha256:9f304a22ece735a3da8a51309bc2c010e23961a8f675fae46fdf62541ed62123"}, - {file = "websockets-10.1-cp37-cp37m-musllinux_1_1_i686.whl", hash = "sha256:189ed478395967d6a98bb293abf04e8815349e17456a0a15511f1088b6cb26e4"}, - {file = "websockets-10.1-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:08a42856158307e231b199671c4fce52df5786dd3d703f36b5d8ac76b206c485"}, - {file = "websockets-10.1-cp37-cp37m-win32.whl", hash = "sha256:3ef6f73854cded34e78390dbdf40dfdcf0b89b55c0e282468ef92646fce8d13a"}, - {file = "websockets-10.1-cp37-cp37m-win_amd64.whl", hash = "sha256:89e985d40d407545d5f5e2e58e1fdf19a22bd2d8cd54d20a882e29f97e930a0a"}, - {file = "websockets-10.1-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:002071169d2e44ce8eb9e5ebac9fbce142ba4b5146eef1cfb16b177a27662657"}, - {file = "websockets-10.1-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:cfae282c2aa7f0c4be45df65c248481f3509f8c40ca8b15ed96c35668ae0ff69"}, - {file = "websockets-10.1-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:97b4b68a2ddaf5c4707ae79c110bfd874c5be3c6ac49261160fb243fa45d8bbb"}, - {file = "websockets-10.1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:7c9407719f42cb77049975410490c58a705da6af541adb64716573e550e5c9db"}, - {file = "websockets-10.1-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:1d858fb31e5ac992a2cdf17e874c95f8a5b1e917e1fb6b45ad85da30734b223f"}, - {file = "websockets-10.1-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:7bdd3d26315db0a9cf8a0af30ca95e0aa342eda9c1377b722e71ccd86bc5d1dd"}, - {file = "websockets-10.1-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:e259be0863770cb91b1a6ccf6907f1ac2f07eff0b7f01c249ed751865a70cb0d"}, - {file = "websockets-10.1-cp38-cp38-musllinux_1_1_i686.whl", hash = "sha256:6b014875fae19577a392372075e937ebfebf53fd57f613df07b35ab210f31534"}, - {file = "websockets-10.1-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:98de71f86bdb29430fd7ba9997f47a6b10866800e3ea577598a786a785701bb0"}, - {file = "websockets-10.1-cp38-cp38-win32.whl", hash = "sha256:3a02ab91d84d9056a9ee833c254895421a6333d7ae7fff94b5c68e4fa8095519"}, - {file = "websockets-10.1-cp38-cp38-win_amd64.whl", hash = "sha256:7d6673b2753f9c5377868a53445d0c321ef41ff3c8e3b6d57868e72054bfce5f"}, - {file = "websockets-10.1-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:ddab2dc69ee5ae27c74dbfe9d7bb6fee260826c136dca257faa1a41d1db61a89"}, - {file = "websockets-10.1-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:14e9cf68a08d1a5d42109549201aefba473b1d925d233ae19035c876dd845da9"}, - {file = "websockets-10.1-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:e4819c6fb4f336fd5388372cb556b1f3a165f3f68e66913d1a2fc1de55dc6f58"}, - {file = "websockets-10.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:05e7f098c76b0a4743716590bb8f9706de19f1ef5148d61d0cf76495ec3edb9c"}, - {file = "websockets-10.1-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:5bb6256de5a4fb1d42b3747b4e2268706c92965d75d0425be97186615bf2f24f"}, - {file = "websockets-10.1-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:888a5fa2a677e0c2b944f9826c756475980f1b276b6302e606f5c4ff5635be9e"}, - {file = "websockets-10.1-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:6fdec1a0b3e5630c58e3d8704d2011c678929fce90b40908c97dfc47de8dca72"}, - {file = "websockets-10.1-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:531d8eb013a9bc6b3ad101588182aa9b6dd994b190c56df07f0d84a02b85d530"}, - {file = "websockets-10.1-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:0d93b7cadc761347d98da12ec1930b5c71b2096f1ceed213973e3cda23fead9c"}, - {file = "websockets-10.1-cp39-cp39-win32.whl", hash = "sha256:d9b245db5a7e64c95816e27d72830e51411c4609c05673d1ae81eb5d23b0be54"}, - {file = "websockets-10.1-cp39-cp39-win_amd64.whl", hash = "sha256:882c0b8bdff3bf1bd7f024ce17c6b8006042ec4cceba95cf15df57e57efa471c"}, - {file = "websockets-10.1-pp37-pypy37_pp73-macosx_10_9_x86_64.whl", hash = "sha256:10edd9d7d3581cfb9ff544ac09fc98cab7ee8f26778a5a8b2d5fd4b0684c5ba5"}, - {file = "websockets-10.1-pp37-pypy37_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:baa83174390c0ff4fc1304fbe24393843ac7a08fdd59295759c4b439e06b1536"}, - {file = "websockets-10.1-pp37-pypy37_pp73-manylinux_2_5_i686.manylinux1_i686.manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:483edee5abed738a0b6a908025be47f33634c2ad8e737edd03ffa895bd600909"}, - {file = "websockets-10.1-pp37-pypy37_pp73-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:816ae7dac2c6522cfa620947ead0ca95ac654916eebf515c94d7c28de5601a6e"}, - {file = "websockets-10.1-pp37-pypy37_pp73-win_amd64.whl", hash = "sha256:1dafe98698ece09b8ccba81b910643ff37198e43521d977be76caf37709cf62b"}, - {file = "websockets-10.1.tar.gz", hash = "sha256:181d2b25de5a437b36aefedaf006ecb6fa3aa1328ec0236cdde15f32f9d3ff6d"}, -] xdoctest = [ {file = "xdoctest-1.1.0-py3-none-any.whl", hash = "sha256:da330c4dacee51f3c785820bc743188fb6f7c64c5fa1c54bff8836b3cf23d69b"}, {file = "xdoctest-1.1.0.tar.gz", hash = "sha256:0fd4fad7932f0a2f082dfdfb857dd6ca41603757586c39b1e5b4d333fc389f8a"}, diff --git a/pyproject.toml b/pyproject.toml index eb1504c..9013cf4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -50,6 +50,7 @@ typeguard = ">=2.13.3" xdoctest = { extras = ["colors"], version = ">=0.15.10" } myst-parser = { version = ">=0.16.1" } requests = "^2.28.1" +playwright = "^1.27" pytest-playwright = "^0.3.0" pytest-asyncio-cooperative = "^0.28.0" nox-poetry = "^1.0.1" diff --git a/src/psc/app.py b/src/psc/app.py index cb6e8ea..0921b56 100644 --- a/src/psc/app.py +++ b/src/psc/app.py @@ -1,8 +1,8 @@ """Provide a web server to browse the examples.""" import contextlib +from collections.abc import Iterator from pathlib import PurePath from typing import AsyncContextManager -from typing import Iterator from starlette.applications import Starlette from starlette.requests import Request diff --git a/src/psc/fixtures.py b/src/psc/fixtures.py index 73410e0..a4ae999 100644 --- a/src/psc/fixtures.py +++ b/src/psc/fixtures.py @@ -1,11 +1,13 @@ """Automate some testing.""" from __future__ import annotations +import builtins +from collections.abc import Callable +from collections.abc import Generator +from collections.abc import Iterable from dataclasses import dataclass from dataclasses import field from mimetypes import guess_type -from typing import Callable -from typing import Generator from urllib.parse import urlparse import pytest @@ -180,3 +182,56 @@ def _route_handler(route: Route) -> None: # Don't spend 30 seconds on timeout page.set_default_timeout(12000) return page + + +@dataclass +class FakeDocument: + """Pretend to be a DOM that holds values at id's.""" + + values: dict[str, str] = field(default_factory=dict) + log: list[str] = field(default_factory=list) + + +@pytest.fixture +def fake_document() -> Iterable[FakeDocument]: + """Yield a document that cleans up.""" + yield FakeDocument() + + +@dataclass +class ElementNode: + """An element node.""" + + value: str + document: FakeDocument + + def write(self, value: str) -> None: + """Collect anything that is written to the node.""" + self.document.log.append(value) + + def removeAttribute(self, name: str) -> None: # noqa + """Pretend to remove an attribute from this node.""" + pass + + +@dataclass +class ElementCallable: + """A callable that returns an ElementNode.""" + + document: FakeDocument + + def __call__(self, key: str) -> ElementNode: + """Return an ElementNode.""" + value = self.document.values[key] + node = ElementNode(value, self.document) + return node + + +@pytest.fixture +def fake_element(fake_document: FakeDocument) -> None: # type: ignore [misc] + """Install the stateful Element into builtins.""" + try: + builtins.Element = ElementCallable(fake_document) #type: ignore [attr-defined] + yield + finally: + delattr(builtins, "Element") diff --git a/src/psc/gallery/examples/hello_world_py/hello_world.py b/src/psc/gallery/examples/hello_world_py/hello_world.py index 4f4ef4f..d464d41 100644 --- a/src/psc/gallery/examples/hello_world_py/hello_world.py +++ b/src/psc/gallery/examples/hello_world_py/hello_world.py @@ -1,3 +1,3 @@ """Say Hello.""" -output = Element("output") +output = Element("output") #type: ignore output.write("From Python...") diff --git a/src/psc/gallery/examples/hello_world_py/index.html b/src/psc/gallery/examples/hello_world_py/index.html index 8df36eb..ecc14e4 100644 --- a/src/psc/gallery/examples/hello_world_py/index.html +++ b/src/psc/gallery/examples/hello_world_py/index.html @@ -7,9 +7,7 @@ - - paths = ["hello_world.py"] - +

Hello Python ...

diff --git a/src/psc/gallery/examples/interest_calculator/calculator.py b/src/psc/gallery/examples/interest_calculator/calculator.py new file mode 100644 index 0000000..d9e1d70 --- /dev/null +++ b/src/psc/gallery/examples/interest_calculator/calculator.py @@ -0,0 +1,26 @@ +def interest(*args, **kwargs): + """Main interest calculation function.""" + # Signal that PyScript is alive by setting the ``Calculate`` + # button away from disabled. + calculate_button = Element("calc") # noqa + # calculate_button.element.setAttribute("disabled") + + # Now get the various inputs + element_principal = Element("principal") # noqa + element_rate = Element("interest_rate") # noqa + element_time = Element("time") # noqa + principal = float(element_principal.value) + rate = float(element_rate.value) + time = float(element_time.value) + output1 = Element("simple_interest") # noqa + output2 = Element("compound_interest") # noqa + res1 = round(principal + (principal * rate * time)) + res2 = round(principal * ((1 + rate) ** time)) + output1.write(f"simple interest: {res1}") + output2.write(f"compound interest: {res2}") + + +def setup(): + """When Pyodide starts up, enable the Calculate button.""" + calculate_button = Element("calc") # noqa + calculate_button.element.removeAttribute("disabled") diff --git a/src/psc/gallery/examples/interest_calculator/compound-interest.png b/src/psc/gallery/examples/interest_calculator/compound-interest.png new file mode 100644 index 0000000..2a1c345 Binary files /dev/null and b/src/psc/gallery/examples/interest_calculator/compound-interest.png differ diff --git a/src/psc/gallery/examples/interest_calculator/index.html b/src/psc/gallery/examples/interest_calculator/index.html new file mode 100644 index 0000000..311aa2e --- /dev/null +++ b/src/psc/gallery/examples/interest_calculator/index.html @@ -0,0 +1,92 @@ + + + + Interest Calculator + + + + + + +
+
+
+

+ Welcome to the "Simple and Compound Interest Calculator!" +
+ "how does it work?" + to use the "Simple and Compound Interest Calculator", please enter the input data into the form. + after clicking "Calculate", your result will be shown at the bottom of the form. +

+ +
+
+ + + Compound Interest +
+ +
+ + + Simple Interest +
+
+
+ + +
+ +
+ +
+ +

+ +
+
+ + +

+ + + +
+ +
+ +
+ +
+ +
+ +
+ + + + + setup() + +
+
+ + + + + + + diff --git a/src/psc/gallery/examples/interest_calculator/index.md b/src/psc/gallery/examples/interest_calculator/index.md new file mode 100644 index 0000000..35b0a54 --- /dev/null +++ b/src/psc/gallery/examples/interest_calculator/index.md @@ -0,0 +1,5 @@ +--- +title: Compound Interest Calculator +subtitle: The classic hello world, but in Python -- in a browser! +--- +The *body* description. diff --git a/src/psc/gallery/examples/interest_calculator/simple-interest.png b/src/psc/gallery/examples/interest_calculator/simple-interest.png new file mode 100644 index 0000000..abba5f6 Binary files /dev/null and b/src/psc/gallery/examples/interest_calculator/simple-interest.png differ diff --git a/src/psc/gallery/examples/interest_calculator/styles.css b/src/psc/gallery/examples/interest_calculator/styles.css new file mode 100644 index 0000000..caaf0b3 --- /dev/null +++ b/src/psc/gallery/examples/interest_calculator/styles.css @@ -0,0 +1,174 @@ +section.calculator-demo { + background-color: #F3F6F8; + min-height: 100vh; + display: flex; + flex-direction: column; + margin: 0; + font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji"; + font-size: 14px; + line-height: 1.5; +} + +section.calculator-inner { + display: flex; + flex-direction: row; +} + +img { + flex: 1; + margin: 5%; + margin-left: 20%; +} + +#first_div { + align-content: center; + margin: 1%; + flex: 1.25; +} + +#first_p { + margin: 3.5%; + margin-left: 15%; + font-family: Tahoma, sans-serif; +} + +.flexelement { + flex: 1; + padding: 2%; +} + + + +#form { + margin-top: 7%; + height: 100%; + display: flex; + align-content: center; + justify-content: center; +} + +#form input[type=number] { + border: 1px solid white; + border-radius: 0.3em; + height: 12%; + width: 100%; + margin-bottom: 5px; +} + + +#form button { + width: 100%; + height: 12%; + margin-bottom: 5px; + border: 0; +} + +#form button:disabled, #form button[disabled] { + background-color: #0097e863; +} + +header { + height: 100px; +} + +footer { + margin-top: auto; + height: 57px; +} + +header, footer { + background-color: #1A1A27; +} + +#header_h1 { + padding-top: 2.2%; + margin-left: 40%; + font-weight: bold; + color: white; +} + +input[type=number] { + padding: 1%; +} + +#principal, #interest_rate, #time { + width: 25%; +} + +#calc { + width: 25%; + padding: 1%; + font-weight: bold; + margin-top: 2%; + color: white; + background-color: #0095E8; +} + +#simple_interest, #compound_interest { + color: black; + font-weight: bold; +} + +input[type=radio] { + display: none; +} + +label { + cursor: pointer; +} + +input[type=radio] ~ img { + animation: close 1.5; + display: none; + height: 0; + max-height: 500px; + overflow: hidden; +} + +input[type=radio]:checked ~ img { + animation: open 1.5s; + display: block; + height: auto; + max-height: 500px; +} + +@keyframes open { + from { + max-height: 0; + } + + to { + max-height: auto; + } +} + +@keyframes close { + from { + display: block; + max-height: auto; + } + + to { + display: none; + height: 0; + } +} + +.expander_label { + border: 1px solid #0095E8; + border-radius: 0.1em; + padding: 1%; + font-weight: 500; + color: white; + background-color: #0095E8; + background-color: #0095E8; +} + +#footer_p { + font-weight: bold; + font-size: 13px; + text-align: center; + color: white; + vertical-align: central; + padding: 1.2%; +} diff --git a/src/psc/pages/contributing.html b/src/psc/pages/contributing.html index 6666ebf..79043a9 100644 --- a/src/psc/pages/contributing.html +++ b/src/psc/pages/contributing.html @@ -1,7 +1,7 @@ Contributing - +
diff --git a/src/psc/templates/homepage.jinja2 b/src/psc/templates/homepage.jinja2 index f6fde35..2710c50 100644 --- a/src/psc/templates/homepage.jinja2 +++ b/src/psc/templates/homepage.jinja2 @@ -21,7 +21,7 @@
- Toroid Example + Hello World
diff --git a/tests/examples/test_interest_calculator.py b/tests/examples/test_interest_calculator.py new file mode 100644 index 0000000..9a01cd3 --- /dev/null +++ b/tests/examples/test_interest_calculator.py @@ -0,0 +1,46 @@ +"""Test the ``Antigravity`` example.""" + +import pytest +from playwright.sync_api import Page + +from psc.fixtures import PageT + + +def test_calculator(fake_document, fake_element) -> None: + """Ensure the loaded interest function works correctly.""" + from psc.gallery.examples.interest_calculator.calculator import interest + + fake_document.values["principal"] = "100" + fake_document.values["interest_rate"] = "0.1" + fake_document.values["time"] = "10" + fake_document.values["simple_interest"] = "0.1" + fake_document.values["compound_interest"] = "0.1" + fake_document.values["calc"] = "Calculate" + interest() + assert fake_document.log[0] == "simple interest: 200" + assert fake_document.log[1] == "compound interest: 259" + + +def test_interest_calculator(client_page: PageT) -> None: + """Test the static HTML for Antigravity.""" + soup = client_page("/gallery/examples/interest_calculator/") + title = soup.select_one("title") + assert title and title.text == "Compound Interest Calculator | PyScript Collective" + + +@pytest.mark.full +def test_interest_calculator_full(fake_page: Page) -> None: + """Use Playwright to do a test on Antigravity.""" + # Use `PWDEBUG=1` to run "head-ful" in Playwright test app + url = "http://fake/gallery/examples/interest_calculator/index.html" + fake_page.goto(url) + assert fake_page.title() == "Interest Calculator" + button = fake_page.wait_for_selector("#calc:enabled") + fake_page.get_by_text("Principal").fill("1000") + fake_page.get_by_text("Interest rate").fill("0.1") + fake_page.get_by_text("Time").fill("10") + si = fake_page.query_selector("#simple_interest") + ci = fake_page.query_selector("#compound_interest") + button.click() + assert si.text_content() == "simple interest: 2000" + assert ci.text_content() == "compound interest: 2594" diff --git a/tests/test_fixtures.py b/tests/test_fixtures.py index 0a43b53..955854f 100644 --- a/tests/test_fixtures.py +++ b/tests/test_fixtures.py @@ -7,10 +7,11 @@ from playwright.sync_api import Route from starlette.testclient import TestClient -from psc.fixtures import DummyPage +from psc.fixtures import DummyPage, ElementCallable from psc.fixtures import DummyRequest from psc.fixtures import DummyResponse from psc.fixtures import DummyRoute +from psc.fixtures import FakeDocument from psc.fixtures import MockTestClient from psc.fixtures import PageT from psc.fixtures import mocked_client_page @@ -133,3 +134,37 @@ def test_route_handler_fake_bad_path() -> None: cast(Route, dummy_route), ) assert dummy_route.status == "404" + + +def test_fake_element_not_installed() -> None: + """We don't request the fixture so it isn't available.""" + with pytest.raises(NameError): + Element # noqa + + +def test_fake_element_installed(fake_element: ElementCallable) -> None: + """Element is available as ``fake_element`` installed it.""" + Element # noqa + + +def test_fake_element_find_element(fake_document: FakeDocument, fake_element: ElementCallable) -> None: + """The Element can get a value from the fake document.""" + fake_document.values["btn1"] = "value1" + button = Element("btn1") # noqa + assert button.value == "value1" + + +def test_fake_element_write(fake_document: FakeDocument, fake_element: ElementCallable) -> None: + """The Element can write a value that is captured.""" + fake_document.values["btn1"] = "value1" + button = Element("btn1") # noqa + button.write("Some Value") + assert fake_document.log[0] == "Some Value" + + +def test_fake_element_remove_attribute(fake_document: FakeDocument, fake_element: ElementCallable) -> None: + """The Element can pretend to remove an attribute.""" + fake_document.values["btn1"] = "value1" + button = Element("btn1") # noqa + button.removeAttribute("disabled") + assert fake_document.log == [] diff --git a/tests/test_resources.py b/tests/test_resources.py index 8c701f0..ee1a6d9 100644 --- a/tests/test_resources.py +++ b/tests/test_resources.py @@ -90,7 +90,7 @@ def test_html_page() -> None: """Make an instance of a .html Page resource and test it.""" this_page = Page(path=PurePath("contributing")) assert this_page.title == "Contributing" - assert this_page.subtitle == "How to get involved in the PyCharm Collective." + assert this_page.subtitle == "How to get involved in the PyScript Collective." assert 'id="viewer"' in this_page.body