Skip to content
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

use pyscript next in template #134

Merged
merged 5 commits into from
Feb 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion src/pyscript/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import typer
from rich.console import Console

LATEST_PYSCRIPT_VERSION = "2023.05.1"
LATEST_PYSCRIPT_VERSION = "2023.11.2"
APPNAME = "pyscript"
APPAUTHOR = "python"
DEFAULT_CONFIG_FILENAME = ".pyscriptconfig"
Expand Down
7 changes: 3 additions & 4 deletions src/pyscript/templates/basic.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@
<html lang="en">
<head>
<title>{{ title }}</title>
<link rel="stylesheet" href="https://pyscript.net/releases/{{ pyscript_version }}/pyscript.css"/>
<script defer src="https://pyscript.net/releases/{{ pyscript_version }}/pyscript.js"></script>
<link rel="stylesheet" href="https://pyscript.net/releases/{{ pyscript_version }}/core.css">
<script type="module" src="https://pyscript.net/releases/{{ pyscript_version }}/core.js"></script>
</head>
<body>
<py-config src="./{{ config_file_path }}"></py-config>
<py-script src="./{{ python_file_path }}"></py-script>
<script type="py" src="./{{ python_file_path }}" config="./{{ config_file_path }}"></script>
</body>
</html>
24 changes: 12 additions & 12 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def test_wrap_file(

@pytest.mark.parametrize(
"version, expected_version",
[(None, LATEST_PYSCRIPT_VERSION), ("2022.9.1", "2022.9.1")],
[(None, LATEST_PYSCRIPT_VERSION), ("2023.11.1", "2023.11.1")],
)
def test_wrap_pyscript_version(
invoke_cli: CLIInvoker,
Expand Down Expand Up @@ -173,20 +173,20 @@ def test_wrap_pyscript_version(

# EXPECT the right JS and CSS version to be present in the output file
version_str = (
f'<script defer src="https://pyscript.net/releases/{expected_version}'
'/pyscript.js"></script>'
'<script type="module" src="https://pyscript.net/releases/'
f'{expected_version}/core.js"></script>'
)
css_version_str = (
'<link rel="stylesheet" href="https://pyscript.net/releases/'
f'{expected_version}/pyscript.css"/>'
f'{expected_version}/core.css">'
)
assert version_str in html_text
assert css_version_str in html_text


@pytest.mark.parametrize(
"version, expected_version",
[(None, LATEST_PYSCRIPT_VERSION), ("2022.9.1", "2022.9.1")],
[(None, LATEST_PYSCRIPT_VERSION), ("2023.11.1", "2023.11.1")],
)
def test_wrap_pyscript_version_file(
invoke_cli: CLIInvoker,
Expand Down Expand Up @@ -228,12 +228,12 @@ def test_wrap_pyscript_version_file(

# EXPECT the right JS and CSS version to be present in the output file
version_str = (
f'<script defer src="https://pyscript.net/releases/{expected_version}'
'/pyscript.js"></script>'
'<script type="module" src="https://pyscript.net/releases/'
f'{expected_version}/core.js"></script>'
)
css_version_str = (
'<link rel="stylesheet" href="https://pyscript.net/releases/'
f'{expected_version}/pyscript.css"/>'
f'{expected_version}/core.css">'
)
assert version_str in html_text
assert css_version_str in html_text
Expand All @@ -243,7 +243,7 @@ def test_wrap_pyscript_version_file(
"create_args, expected_version",
[
(("myapp1",), LATEST_PYSCRIPT_VERSION),
(("myapp-w-version", "--pyscript-version", "2022.9.1"), "2022.9.1"),
(("myapp-w-version", "--pyscript-version", "2023.11.1"), "2023.11.1"),
],
)
def test_create_project_version(
Expand Down Expand Up @@ -280,12 +280,12 @@ def test_create_project_version(

# EXPECT the right JS and CSS version to be present in the html file
version_str = (
f'<script defer src="https://pyscript.net/releases/{expected_version}'
'/pyscript.js"></script>'
'<script type="module" src="https://pyscript.net/releases/'
f'{expected_version}/core.js"></script>'
)
css_version_str = (
'<link rel="stylesheet" href="https://pyscript.net/releases/'
f'{expected_version}/pyscript.css"/>'
f'{expected_version}/core.css">'
)
assert version_str in html_text
assert css_version_str in html_text
Expand Down
6 changes: 4 additions & 2 deletions tests/test_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,10 @@ def check_project_files(

with html_file_path.open() as fp:
contents = fp.read()
assert f'<py-script src="./{python_file}">' in contents
assert f'<py-config src="./{config_file}">' in contents
assert (
f'<script type="py" src="./{python_file}" config="./{config_file}">'
in contents
)


def check_plugin_project_files(
Expand Down
Loading