A pytest plugin to enable a hot reloading daemon.
Project description
A PyTest Hot Reloading Plugin
A hot reloading pytest daemon, implemented as a plugin.
This uses the jurigged library to watch files.
If it takes less than 5 seconds to do all of the imports necessary to run a unit test, then you probably don't need this.
Installation
TBD
Usage
Add the plugin to the pytest arguments. Example using pyproject.toml:
[tool.pytest.ini_options]
addopts = "-p pytest_hot_reloading.plugin"
When running pytest, the plugin will detect whether the daemon is running, and start it if is not. Note that a pid file is created to track the pid.
Imports are not reran on subsequent runs, which can be a huge time saver.
Currently, if you want to debug, you will want to run the daemon manually with debugging. This can easily be done in VS Code with the following launch profile:
{
"name": "Pytest Daemon",
"type": "python",
"request": "launch",
"module": "pytest",
"justMyCode": false,
"args": [
"--daemon",
//
// everything below this is optional
//
"--daemon-port",
"4852", // the default value
"--daemon-watch-globs",
"./*.py" // the default value
// "./my-project/*.py:./some-thing-else/*.py", // example of colon separated globs
"--daemon-ignore-watch-globs",
"./.venv/*" // this is the default value, also colon separated globs
]
},
The only reason you would need to limit the watched files is because the jurigged library opens every file it watches, so it can exhaust the open file limit if you have a lot of files.
If the daemon is already running and you run pytest with --daemon
, then the old one will be stopped
and a new one will be started. Note that pytest --daemon
is NOT how you run tests. It is only used to start
the daemon.
Known Issues
- This is early alpha
- The jurigged library is not perfect and sometimes it gets in a bad state
- Some libraries were not written with hot reloading in mind, and will not work without some changes. There is going to be logic to work around other issues with other libraries, such as pytest-django's mutation of the settings module that runs every session, but it hasn't been implemented yet.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for pytest_hot_reloading-0.1.0a2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | f8861034051b8b05320a88adc4230c39c3f503a780fabfc242ac27830e76911b |
|
MD5 | 19a6b6393d976a57d85a09edf345134c |
|
BLAKE2b-256 | 02fa2274250f9f8c98550280fac2f52105bda35fd7b9dbb8c498f2c8fdc5ce22 |
Hashes for pytest_hot_reloading-0.1.0a2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 27301a5ff97ff3e6248058f9ab82863bf70b17f36337ba0ee4b32a6f8b0940e1 |
|
MD5 | a594027ce759e4cec417942c3c9dee5c |
|
BLAKE2b-256 | a014a472c826bd06a0c114d32ef839e7c6e9539b4cd2796b7b88513e9510e19c |