@@ -71,9 +71,11 @@ those who use PyTest, when using PyScript.
71
71
modules.
72
72
7 . The ` result ` of awaiting ` upytest.run ` is a Python dictionary containing
73
73
lists of tests bucketed under the keys: ` "passes" ` , ` "fails" ` and
74
- ` "skipped" ` . These results are JSON serializable and can be used for further
75
- processing and analysis (again, see ` main.py ` for an example of this in
76
- action.)
74
+ ` "skipped" ` . The result also provides information about the Python
75
+ interpreter used to run the tests, long with a boolean flag to indicate if
76
+ the tests were running in a web worker. These results are JSON serializable
77
+ and can be used for further processing and analysis (again, see ` main.py `
78
+ for an example of this in action.)
77
79
8 . In your ` index.html ` make sure you use the ` terminal ` attribute
78
80
when referencing your Python script (as in the ` index.html ` file in
79
81
this repository):
@@ -83,7 +85,7 @@ those who use PyTest, when using PyScript.
83
85
You should be able to use the ` type ` attribute of ` "mpy" ` (for MicroPython)
84
86
and ` "py" ` (for Pyodide) interchangeably.
85
87
86
- Finally, point your browser at your ` index.html ` and your should see the test
88
+ Finally, point your browser at your ` index.html ` and you should see the test
87
89
suite run.
88
90
89
91
### Writing tests
@@ -208,68 +210,41 @@ The output for the test suite for this module is a good example of all the
208
210
different sorts of information you may see:
209
211
210
212
```
211
- Python interpreter: webassembly 3.4.0; MicroPython v1.24.0-preview.114.g77bd8fe5b on 2024-07-19
212
- Using ./tests/conftest.py for global setup and teardown in ./tests.
213
- Using local setup and teardown for ./ tests/test_with_setup_teardown .py.
214
- Found 2 test module[s]. Running 18 test[s].
213
+ Python interpreter: webassembly 3.4.0; MicroPython v1.24.0-preview.114.g77bd8fe5b on 2024-07-19
214
+ Running in worker: False
215
+ Using tests/conftest.py for global setup and teardown in tests/test_core_functionality .py::TestClass .
216
+ Found 1 test module[s]. Running 8 test[s].
215
217
216
- S.F..FFFS..S.F.SF .
218
+ F.FSSF. .
217
219
================================= FAILURES =================================
218
- Failed: ./ tests/test_core_functionality.py::test_does_not_raise_exception_fails
220
+ Failed: tests/test_core_functionality.py::TestClass. test_does_not_raise_exception_fails
219
221
Traceback (most recent call last):
220
- File "upytest.py", line 147 , in run
221
- File "tests/test_core_functionality.py", line 77 , in test_does_not_raise_exception_fails
222
+ File "upytest.py", line 156 , in run
223
+ File "tests/test_core_functionality.py", line 127 , in test_does_not_raise_exception_fails
222
224
AssertionError: Did not raise expected exception. Expected ValueError; but got None.
223
225
224
226
225
- Failed: ./ tests/test_core_functionality.py::test_fails
227
+ Failed: tests/test_core_functionality.py::TestClass. test_fails
226
228
Traceback (most recent call last):
227
- File "upytest.py", line 147 , in run
228
- File "tests/test_core_functionality.py", line 46 , in test_fails
229
+ File "upytest.py", line 156 , in run
230
+ File "tests/test_core_functionality.py", line 119 , in test_fails
229
231
AssertionError: This test will fail
230
232
231
233
232
- Failed: ./tests/test_core_functionality.py::test_async_does_not_raise_exception_fails
233
- Traceback (most recent call last):
234
- File "upytest.py", line 145, in run
235
- File "tests/test_core_functionality.py", line 121, in test_async_does_not_raise_exception_fails
236
- AssertionError: Did not raise expected exception. Expected ValueError; but got None.
237
-
238
-
239
- Failed: ./tests/test_core_functionality.py::test_async_does_not_raise_expected_exception_fails
240
- Traceback (most recent call last):
241
- File "upytest.py", line 145, in run
242
- File "tests/test_core_functionality.py", line 126, in test_async_does_not_raise_expected_exception_fails
243
- AssertionError: Did not raise expected exception. Expected ValueError, AssertionError; but got TypeError.
244
-
245
-
246
- Failed: ./tests/test_core_functionality.py::test_does_not_raise_expected_exception_fails
234
+ Failed: tests/test_core_functionality.py::TestClass.test_does_not_raise_expected_exception_fails
247
235
Traceback (most recent call last):
248
- File "upytest.py", line 147 , in run
249
- File "tests/test_core_functionality.py", line 85 , in test_does_not_raise_expected_exception_fails
236
+ File "upytest.py", line 156 , in run
237
+ File "tests/test_core_functionality.py", line 131 , in test_does_not_raise_expected_exception_fails
250
238
AssertionError: Did not raise expected exception. Expected ValueError, AssertionError; but got TypeError.
251
239
252
-
253
- Failed: ./tests/test_core_functionality.py::test_async_fails
254
- Traceback (most recent call last):
255
- File "upytest.py", line 145, in run
256
- File "tests/test_core_functionality.py", line 111, in test_async_fails
257
- AssertionError: This async test fails.
258
-
259
240
================================= SKIPPED ==================================
260
- Skipped: ./tests/test_core_functionality.py::test_when_skipped
261
- Reason: This test will be skipped with a when condition
262
-
263
- Skipped: ./tests/test_core_functionality.py::test_async_when_skipped
264
- Reason: This test will be skipped with a when condition
265
-
266
- Skipped: ./tests/test_core_functionality.py::test_async_skipped
267
- Reason: This async test will be skipped
268
-
269
- Skipped: ./tests/test_core_functionality.py::test_skipped
241
+ Skipped: tests/test_core_functionality.py::TestClass.test_skipped
270
242
Reason: This test will be skipped
243
+
244
+ Skipped: tests/test_core_functionality.py::TestClass.test_when_skipped
245
+ Reason: This test will be skipped with a skip_when condition
271
246
========================= short test summary info ==========================
272
- 6 failed, 4 skipped, 8 passed in 0.00 seconds
247
+ 3 failed, 2 skipped, 3 passed in 0.00 seconds
273
248
```
274
249
275
250
## Developer setup
0 commit comments