Skip to content

Commit 3946708

Browse files
use pyscript next in template (#134)
* use pyscript next in template * fix tests * replace 2022.9.1 with 2023.11.1 for older versions --------- Co-authored-by: Fábio Rosado <hello@fabiorosado.dev>
1 parent 3c76353 commit 3946708

File tree

4 files changed

+20
-19
lines changed

4 files changed

+20
-19
lines changed

src/pyscript/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import typer
88
from rich.console import Console
99

10-
LATEST_PYSCRIPT_VERSION = "2023.05.1"
10+
LATEST_PYSCRIPT_VERSION = "2023.11.2"
1111
APPNAME = "pyscript"
1212
APPAUTHOR = "python"
1313
DEFAULT_CONFIG_FILENAME = ".pyscriptconfig"

src/pyscript/templates/basic.html

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@
22
<html lang="en">
33
<head>
44
<title>{{ title }}</title>
5-
<link rel="stylesheet" href="https://pyscript.net/releases/{{ pyscript_version }}/pyscript.css"/>
6-
<script defer src="https://pyscript.net/releases/{{ pyscript_version }}/pyscript.js"></script>
5+
<link rel="stylesheet" href="https://pyscript.net/releases/{{ pyscript_version }}/core.css">
6+
<script type="module" src="https://pyscript.net/releases/{{ pyscript_version }}/core.js"></script>
77
</head>
88
<body>
9-
<py-config src="./{{ config_file_path }}"></py-config>
10-
<py-script src="./{{ python_file_path }}"></py-script>
9+
<script type="py" src="./{{ python_file_path }}" config="./{{ config_file_path }}"></script>
1110
</body>
1211
</html>

tests/test_cli.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ def test_wrap_file(
136136

137137
@pytest.mark.parametrize(
138138
"version, expected_version",
139-
[(None, LATEST_PYSCRIPT_VERSION), ("2022.9.1", "2022.9.1")],
139+
[(None, LATEST_PYSCRIPT_VERSION), ("2023.11.1", "2023.11.1")],
140140
)
141141
def test_wrap_pyscript_version(
142142
invoke_cli: CLIInvoker,
@@ -173,20 +173,20 @@ def test_wrap_pyscript_version(
173173

174174
# EXPECT the right JS and CSS version to be present in the output file
175175
version_str = (
176-
f'<script defer src="https://pyscript.net/releases/{expected_version}'
177-
'/pyscript.js"></script>'
176+
'<script type="module" src="https://pyscript.net/releases/'
177+
f'{expected_version}/core.js"></script>'
178178
)
179179
css_version_str = (
180180
'<link rel="stylesheet" href="https://pyscript.net/releases/'
181-
f'{expected_version}/pyscript.css"/>'
181+
f'{expected_version}/core.css">'
182182
)
183183
assert version_str in html_text
184184
assert css_version_str in html_text
185185

186186

187187
@pytest.mark.parametrize(
188188
"version, expected_version",
189-
[(None, LATEST_PYSCRIPT_VERSION), ("2022.9.1", "2022.9.1")],
189+
[(None, LATEST_PYSCRIPT_VERSION), ("2023.11.1", "2023.11.1")],
190190
)
191191
def test_wrap_pyscript_version_file(
192192
invoke_cli: CLIInvoker,
@@ -228,12 +228,12 @@ def test_wrap_pyscript_version_file(
228228

229229
# EXPECT the right JS and CSS version to be present in the output file
230230
version_str = (
231-
f'<script defer src="https://pyscript.net/releases/{expected_version}'
232-
'/pyscript.js"></script>'
231+
'<script type="module" src="https://pyscript.net/releases/'
232+
f'{expected_version}/core.js"></script>'
233233
)
234234
css_version_str = (
235235
'<link rel="stylesheet" href="https://pyscript.net/releases/'
236-
f'{expected_version}/pyscript.css"/>'
236+
f'{expected_version}/core.css">'
237237
)
238238
assert version_str in html_text
239239
assert css_version_str in html_text
@@ -243,7 +243,7 @@ def test_wrap_pyscript_version_file(
243243
"create_args, expected_version",
244244
[
245245
(("myapp1",), LATEST_PYSCRIPT_VERSION),
246-
(("myapp-w-version", "--pyscript-version", "2022.9.1"), "2022.9.1"),
246+
(("myapp-w-version", "--pyscript-version", "2023.11.1"), "2023.11.1"),
247247
],
248248
)
249249
def test_create_project_version(
@@ -280,12 +280,12 @@ def test_create_project_version(
280280

281281
# EXPECT the right JS and CSS version to be present in the html file
282282
version_str = (
283-
f'<script defer src="https://pyscript.net/releases/{expected_version}'
284-
'/pyscript.js"></script>'
283+
'<script type="module" src="https://pyscript.net/releases/'
284+
f'{expected_version}/core.js"></script>'
285285
)
286286
css_version_str = (
287287
'<link rel="stylesheet" href="https://pyscript.net/releases/'
288-
f'{expected_version}/pyscript.css"/>'
288+
f'{expected_version}/core.css">'
289289
)
290290
assert version_str in html_text
291291
assert css_version_str in html_text

tests/test_generator.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,10 @@ def check_project_files(
190190

191191
with html_file_path.open() as fp:
192192
contents = fp.read()
193-
assert f'<py-script src="./{python_file}">' in contents
194-
assert f'<py-config src="./{config_file}">' in contents
193+
assert (
194+
f'<script type="py" src="./{python_file}" config="./{config_file}">'
195+
in contents
196+
)
195197

196198

197199
def check_plugin_project_files(

0 commit comments

Comments
 (0)