You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Fix: Restored the development docs pyscript#1783
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Andrea Giammarchi <andrea.giammarchi@gmail.com>
Copy file name to clipboardExpand all lines: CONTRIBUTING.md
+100Lines changed: 100 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -79,3 +79,103 @@ The Project abides by the Organization's [trademark policy](https://github.com/p
79
79
80
80
Part of MVG-0.1-beta.
81
81
Made with love by GitHub. Licensed under the [CC-BY 4.0 License](https://creativecommons.org/licenses/by-sa/4.0/).
82
+
83
+
# Quick guide to pytest
84
+
85
+
We make heavy usage of pytest. Here is a quick guide and collection of useful options:
86
+
87
+
- To run all tests in the current directory and subdirectories: pytest
88
+
89
+
- To run tests in a specific directory or file: pytest path/to/dir/test_foo.py
90
+
91
+
- -s: disables output capturing
92
+
93
+
- --pdb: in case of exception, enter a (Pdb) prompt so that you can inspect what went wrong.
94
+
95
+
- -v: verbose mode
96
+
97
+
- -x: stop the execution as soon as one test fails
98
+
99
+
- -k foo: run only the tests whose full name contains foo
100
+
101
+
- -k 'foo and bar'
102
+
103
+
- -k 'foo and not bar'
104
+
105
+
## Running integration tests under pytest
106
+
107
+
make test is useful to run all the tests, but during the development is useful to have more control on how tests are run. The following guide assumes that you are in the directory pyscriptjs/tests/integration/.
108
+
109
+
### To run all the integration tests, single or multi core
-x means "stop at the first failure". -v means "verbose", so that you can see all the test names one by one. We try to keep tests in a reasonable order, from most basic to most complex. This way, if you introduced some bug in very basic things, you will notice immediately.
123
+
124
+
If you have the pytest-xdist plugin installed, you can run all the integration tests on 4 cores in parallel:
-k selects tests by pattern matching as described above. -s instructs pytest to show the output to the terminal instead of capturing it. In the output you can see various useful things, including network requests and JS console messages.
Same as above, but with --headed the browser is shown in a window, and you can interact with it. The browser uses a fake server, which means that HTTP requests are cached.
149
+
150
+
Unfortunately, in this mode source maps does not seem to work, and you cannot debug the original typescript source code. This seems to be a bug in playwright, for which we have a workaround:
--dev implies --headed --no-fake-server. In addition, it also automatically open chrome dev tools.
163
+
164
+
### To run only main thread or worker tests
165
+
166
+
By default, we run each test twice: one with execution_thread = "main" and one with execution_thread = "worker". If you want to run only half of them, you can use -m:
167
+
168
+
$ pytest -m main # run only the tests in the main thread
169
+
$ pytest -m worker # ron only the tests in the web worker
170
+
171
+
## Fake server, HTTP cache
172
+
173
+
By default, our test machinery uses a playwright router which intercepts and cache HTTP requests, so that for example you don't have to download pyodide again and again. This also enables the possibility of running tests in parallel on multiple cores.
174
+
175
+
The cache is stored using the pytest-cache plugin, which means that it survives across sessions.
176
+
177
+
If you want to temporarily disable the cache, the easiest thing is to use --no-fake-server, which bypasses it completely.
178
+
179
+
If you want to clear the cache, you can use the special option --clear-http-cache:
180
+
181
+
NOTE: this works only if you are inside tests/integration, or if you explicitly specify tests/integration from the command line. This is due to how pytest decides to search for and load the various conftest.py.
0 commit comments