8000 remove PY_COMPLETE and the associated message of `Python initializati… · ocdex/pyscript@f3db6a3 · GitHub
[go: up one dir, main page]

Skip to content

Commit f3db6a3

Browse files
remove PY_COMPLETE and the associated message of Python initialization complete (pyscript#1373)
* remove PY_COMPLETE * fix test_multiple_async
1 parent c05195c commit f3db6a3

14 files changed

+2
-73
lines changed

pyscriptjs/src/plugins/pyterminal.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,7 @@ export class PyTerminalPlugin extends Plugin {
6767
// 3. everything which was written to stdout BEFORE this moment will
6868
// NOT be shown on the py-terminal; in particular, pyodide
6969
// startup messages will not be shown (but they will go to the
70-
// console as usual). This is by design, else we would display
71-
// e.g. "Python initialization complete" on every page, which we
72-
// don't want.
70+
// console as usual).
7371
//
7472
// 4. (in the future we might want to add an option to start the
7573
// capture earlier, but I don't think it's important now).

pyscriptjs/src/remote_interpreter.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,6 @@ export class RemoteInterpreter extends Object {
136136
await this.loadPackage('micropip');
137137
}
138138
logger.info('pyodide loaded and initialized');
139-
this.pyscript_py._run_pyscript('print("Python initialization complete")');
140139
}
141140

142141
/**

pyscriptjs/tests/integration/support.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,6 @@ class PyScriptTest:
4646
creates an HTML page to run the specified snippet.
4747
"""
4848

49-
# Pyodide always print()s this message upon initialization. Make it
50-
# available to all tests so that it's easiert to check.
51-
PY_COMPLETE = "Python initialization complete"
52-
5349
@pytest.fixture()
5450
def init(self, request, tmpdir, logger, page):
5551
"""

pyscriptjs/tests/integration/test_01_basic.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ def test_pyscript_hello(self):
1414
</py-script>
1515
"""
1616
)
17-
assert self.console.log.lines[0] == self.PY_COMPLETE
1817
assert self.console.log.lines[-1] == "hello pyscript"
1918

2019
def test_python_exception(self):
@@ -26,7 +25,6 @@ def test_python_exception(self):
2625
</py-script>
2726
"""
2827
)
29-
assert self.console.log.lines[0] == self.PY_COMPLETE
3028
assert "hello pyscript" in self.console.log.lines
3129
# check that we sent the traceback to the console
3230
tb_lines = self.console.error.lines[-1].splitlines()
@@ -80,7 +78,6 @@ def test_execution_in_order(self):
8078
<py-script>js.console.log('four')</py-script>
8179
"""
8280
)
83-
assert self.console.log.lines[0] == self.PY_COMPLETE
8481
assert self.console.log.lines[-4:] == [
8582
"one",
8683
"two",
@@ -99,7 +96,6 @@ def test_escaping_of_angle_brackets(self):
9996
"""
10097
)
10198

102-
assert self.console.log.lines[0] == self.PY_COMPLETE
10399
assert self.console.log.lines[-2:] == ["true false", "<div></div>"]
104100

105101
def test_packages(self):
@@ -118,7 +114,6 @@ def test_packages(self):
118114
"""
119115
)
120116

121-
assert self.console.log.lines[0] == self.PY_COMPLETE
122117
assert self.console.log.lines[-3:] == [
123118
"Loading asciitree", # printed by pyodide
124119
"Loaded asciitree", # printed by pyodide
@@ -178,7 +173,6 @@ def test_dynamically_add_py_script_tag(self):
178173
self.page.locator("button").click()
179174

180175
self.page.wait_for_selector("py-terminal")
181-
assert self.console.log.lines[0] == self.PY_COMPLETE
182176
assert self.console.log.lines[-1] == "hello world"
183177

184178
def test_py_script_src_attribute(self):
@@ -188,7 +182,6 @@ def test_py_script_src_attribute(self):
188182
<py-script src="foo.py"></py-script>
189183
"""
190184
)
191-
assert self.console.log.lines[0] == self.PY_COMPLETE
192185
assert self.console.log.lines[-1] == "hello from foo"
193186

194187
def test_py_script_src_not_found(self):
@@ -198,8 +191,6 @@ def test_py_script_src_not_found(self):
198191
<py-script src="foo.py"></py-script>
199192
"""
200193
)
201-
assert self.PY_COMPLETE in self.console.log.lines
202-
203194
assert "Failed to load resource" in self.console.error.lines[0]
204195

205196
error_msgs = str(exc.value)

pyscriptjs/tests/integration/test_02_display.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,6 @@ def test_text_HTML_and_console_output(self):
355355
)
356356
inner_text = self.page.inner_text("py-script")
357357
assert inner_text == "this goes to the DOM"
358-
assert self.console.log.lines[0] == self.PY_COMPLETE
359358
assert self.console.log.lines[-2:] == [
360359
"print from python",
361360
"print from js",

pyscriptjs/tests/integration/test_03_element.py

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ def test_element_id(self):
1616
</py-script>
1717
"""
1818
)
19-
assert self.console.log.lines[0] == self.PY_COMPLETE
2019
assert self.console.log.lines[-1] == "foo"
2120

2221
py_terminal = self.page.wait_for_selector("py-terminal")
@@ -34,7 +33,6 @@ def test_element_value(self):
3433
</py-script>
3534
"""
3635
)
37-
assert self.console.log.lines[0] == self.PY_COMPLETE
3836
assert self.console.log.lines[-1] == "bar"
3937

4038
py_terminal = self.page.wait_for_selector("py-terminal")
@@ -52,7 +50,6 @@ def test_element_innerHtml(self):
5250
</py-script>
5351
"""
5452
)
55-
assert self.console.log.lines[0] == self.PY_COMPLETE
5653
assert self.console.log.lines[-1] == "<b>bar</b>"
5754

5855
py_terminal = self.page.wait_for_selector("py-terminal")
@@ -71,8 +68,6 @@ def test_element_write_no_append(self):
7168
</py-script>
7269
"""
7370
)
74-
assert self.console.log.lines[0] == self.PY_COMPLETE
75-
7671
div = self.page.wait_for_selector("#foo")
7772
assert "World!" in div.inner_text()
7873

@@ -89,8 +84,6 @@ def test_element_write_append(self):
8984
</py-script>
9085
"""
9186
)
92-
assert self.console.log.lines[0] == self.PY_COMPLETE
93-
9487
parent_div = self.page.wait_for_selector("#foo")
9588

9689
assert "Hello!" in parent_div.inner_text()
@@ -109,8 +102,6 @@ def test_element_clear_div(self):
109102
</py-script>
110103
"""
111104
)
112-
assert self.console.log.lines[0] == self.PY_COMPLETE
113-
114105
div = self.page.locator("#foo")
115106
assert div.inner_text() == ""
116107

@@ -126,8 +117,6 @@ def test_element_clear_input(self):
126117
</py-script>
127118
"""
128119
)
129-
assert self.console.log.lines[0] == self.PY_COMPLETE
130-
131120
input = self.page.wait_for_selector("#foo")
132121
assert input.input_value() == ""
133122

@@ -145,8 +134,6 @@ def test_element_select(self):
145134
</py-script>
146135
"""
147136
)
148-
assert self.console.log.lines[0] == self.PY_COMPLETE
149-
150137
select = self.page.wait_for_selector("#foo")
151138
assert select.inner_text() == "Bar"
152139

@@ -162,8 +149,6 @@ def test_element_clone_no_id(self):
162149
</py-script>
163150
"""
164151
)
165-
assert self.console.log.lines[0] == self.PY_COMPLETE
166-
167152
divs = self.page.locator("#foo")
168153
assert divs.count() == 2
169154
assert divs.first.inner_text() == "Hello!"
@@ -181,8 +166,6 @@ def test_element_clone_with_id(self):
181166
</py-script>
182167
"""
183168
)
184-
assert self.console.log.lines[0] == self.PY_COMPLETE
185-
186169
divs = self.page.locator("#foo")
187170
assert divs.count() == 1
188171
assert divs.inner_text() == "Hello!"
@@ -212,8 +195,6 @@ def test_element_clone_to_other_element(self):
212195
</py-script>
213196
"""
214197
)
215-
assert self.console.log.lines[0] == self.PY_COMPLETE
216-
217198
bond_divs = self.page.locator("#bond")
218199
james_divs = self.page.locator("#james")
219200
bond_2_divs = self.page.locator("#bond-2")
@@ -238,8 +219,6 @@ def test_element_remove_single_class(self):
238219
</py-script>
239220
"""
240221
)
241-
assert self.console.log.lines[0] == self.PY_COMPLETE
242-
243222
div = self.page.locator("#foo")
244223
assert div.get_attribute("class") == "baz"
245224

@@ -255,8 +234,6 @@ def test_element_remove_multiple_classes(self):
255234
</py-script>
256235
"""
257236
)
258-
assert self.console.log.lines[0] == self.PY_COMPLETE
259-
260237
div = self.page.locator("#foo")
261238
assert div.get_attribute("class") == ""
262239

@@ -273,8 +250,6 @@ def test_element_add_single_class(self):
273250
</py-script>
274251
"""
275252
)
276-
assert self.console.log.lines[0] == self.PY_COMPLETE
277-
278253
div = self.page.locator("#foo")
279254
assert div.get_attribute("class") == "red"
280255

@@ -291,7 +266,5 @@ def test_element_add_multiple_class(self):
291266
</py-script>
292267
"""
293268
)
294-
assert self.console.log.lines[0] == self.PY_COMPLETE
295-
296269
div = self.page.locator("#foo")
297270
assert div.get_attribute("class") == "red bold"

pyscriptjs/tests/integration/test_async.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,11 @@ async def main():
2020
def test_asyncio_ensure_future(self):
2121
self.pyscript_run(self.coroutine_script.format(func="ensure_future"))
2222
self.wait_for_console("third")
23-
assert self.console.log.lines[0] == self.PY_COMPLETE
2423
assert self.console.log.lines[-3:] == ["first", "second", "third"]
2524

2625
def test_asyncio_create_task(self):
2726
self.pyscript_run(self.coroutine_script.format(func="create_task"))
2827
self.wait_for_console("third")
29-
assert self.console.log.lines[0] == self.PY_COMPLETE
3028
assert self.console.log.lines[-3:] == ["first", "second", "third"]
3129

3230
def test_asyncio_gather(self):
@@ -79,8 +77,7 @@ async def b_func():
7977
"""
8078
)
8179
self.wait_for_console("b func done")
82-
assert self.console.log.lines[0] == self.PY_COMPLETE
83-
assert self.console.log.lines[1:] == [
80+
assert self.console.log.lines == [
8481
"A 0",
8582
"B 0",
8683
"A 1",

pyscriptjs/tests/integration/test_importmap.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ def test_importmap(self):
3636
)
3737
assert self.console.log.lines == [
3838
"hello from JS",
39-
self.PY_COMPLETE,
4039
"hello from Python",
4140
]
4241

@@ -59,7 +58,6 @@ def test_invalid_json(self):
5958

6059
self.wait_for_pyscript()
6160
assert self.console.log.lines == [
62-
self.PY_COMPLETE,
6361
"hello world",
6462
]
6563
# this warning is shown by pyscript, when *we* try to parse the import

pyscriptjs/tests/integration/test_interpreter.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ def py_func():
2424
console.log(`py_func() returns ${py_func_res}`);
2525
"""
2626
)
27-
assert self.console.log.lines[0] == self.PY_COMPLETE
2827
assert self.console.log.lines[-2:] == [
2928
"x is 1",
3029
"py_func() returns 2",
@@ -42,7 +41,6 @@ def test_interpreter_script_execution(self):
4241
)
4342

4443
expected_message = "Interpreter Ran This"
45-
assert self.console.log.lines[0] == self.PY_COMPLETE
4644
assert self.console.log.lines[-1] == expected_message
4745

4846
py_terminal = self.page.wait_for_selector("py-terminal")
@@ -60,7 +58,6 @@ def test_backward_compatibility_runtime_script_execution(self):
6058
)
6159

6260
expected_message = "Interpreter Ran This"
63-
assert self.console.log.lines[0] == self.PY_COMPLETE
6461
assert self.console.log.lines[-1] == expected_message
6562

6663
py_terminal = self.page.wait_for_selector("py-terminal")
@@ -88,7 +85,6 @@ def py_func():
8885
"""
8986
)
9087

91-
assert self.console.log.lines[0] == self.PY_COMPLETE
9288
assert self.console.log.lines[-2:] == [
9389
"x is 1",
9490
"py_func() returns 2",

pyscriptjs/tests/integration/test_py_config.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,6 @@ def test_paths(self):
270270
</py-script>
271271
"""
272272
)
273-
assert self.console.log.lines[0] == self.PY_COMPLETE
274273
assert self.console.log.lines[-2:] == [
275274
"hello from A",
276275
"hello from B",
@@ -313,5 +312,4 @@ def test_paths_from_packages(self):
313312
</py-script>
314313
"""
315314
)
316-
assert self.console.log.lines[0] == self.PY_COMPLETE
317315
assert self.console.log.lines[-1] == "hello from A"

pyscriptjs/tests/integration/test_py_repl.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ def test_execute_on_shift_enter(self):
7474
self.page.keyboard.press("Shift+Enter")
7575
self.page.wait_for_selector("py-terminal")
7676

77-
assert self.console.log.lines[0] == self.PY_COMPLETE
7877
assert self.console.log.lines[-1] == "hello world"
7978

8079
# Shift-enter should not add a newline to the editor
@@ -585,7 +584,6 @@ def test_repl_load_content_from_src(self):
585584
"""
586585
)
587586
successMsg = "[py-repl] loading code from ./loadReplSrc1.py to repl...success"
588-
assert self.console.log.lines[0] == self.PY_COMPLETE
589587
assert self.console.info.lines[-1] == successMsg
590588

591589
py_repl = self.page.locator("py-repl")
@@ -610,7 +608,6 @@ def test_repl_src_change(self):
610608
)
611609

612610
successMsg1 = "[py-repl] loading code from ./loadReplSrc2.py to repl...success"
613-
assert self.console.log.lines[0] == self.PY_COMPLETE
614611
assert self.console.info.lines[-1] == successMsg1
615612

616613
py_repl3 = self.page.locator("py-repl#py-repl3")
@@ -635,5 +632,4 @@ def test_repl_src_path_that_do_not_exist(self):
635632
"failed with error 404 (Not Found). "
636633
"Are your filename and path correct?"
637634
)
638-
assert self.console.log.lines[0] == self.PY_COMPLETE
639635
assert self.console.error.lines[-1] == errorMsg

pyscriptjs/tests/integration/test_py_terminal.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@ def test_py_terminal(self):
99
1. <py-terminal> should redirect stdout and stderr to the DOM
1010
1111
2. they also go to the console as usual
12-
13-
3. note that the console also contains PY_COMPLETE, which is a pyodide
14-
initialization message, but py-terminal doesn't. This is by design
1512
"""
1613
self.pyscript_run(
1714
"""

pyscriptjs/tests/integration/test_splashscreen.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ def test_autoshow_and_autoclose(self):
3636
expect(div).to_be_hidden()
3737
assert self.page.locator("py-locator").count() == 0
3838

39-
assert self.console.log.lines[0] == self.PY_COMPLETE
4039
assert "hello pyscript" in self.console.log.lines
4140

4241
def test_autoclose_false(self):
@@ -55,7 +54,6 @@ def test_autoclose_false(self):
5554
expect(div).to_be_visible()
5655
expect(div).to_contain_text("Python startup...")
5756
expect(div).to_contain_text("Startup complete")
58-
assert self.console.log.lines[0] == self.PY_COMPLETE
5957
assert "hello pyscript" in self.console.log.lines
6058

6159
def test_autoclose_loader_deprecated(self):
@@ -77,7 +75,6 @@ def test_autoclose_loader_deprecated(self):
7775
expect(div).to_be_visible()
7876
expect(div).to_contain_text("Python startup...")
7977
expect(div).to_contain_text("Startup complete")
80-
assert self.console.log.lines[0] == self.PY_COMPLETE
8178
assert "hello pyscript" in self.console.log.lines
8279

8380
@pytest.mark.skip(reason="pys-onClick is broken, we should kill it, see #1213")

0 commit comments

Comments
 (0)
0