JamesHutchison / pytest-hot-reloading

A hot reloading pytest daemon, implemented as a plugin
MIT License
89 stars 2 forks source link

Add Pytest bypass mode for client #20

Open JamesHutchison opened 1 year ago

JamesHutchison commented 1 year ago

Since this run as a pytest plugin, there's some overhead from pytest that seems to be difficult to avoid. Specifically, pytest needs to get to the point where it loads its plugins, then from there eventually get to this plugin before switching to the client logic. The developer can have things run even faster by just jumping straight to the client logic. This ticket is to add this functionality in case a developer wants to use it. Here's a simple example that can be added to client.py

if __name__ == "__main__":
    client = PytestClient()
    client.run(sys.argv[1:])

Of course, this is missing the host/port configurability

JamesHutchison commented 1 year ago

A quick measurement shows this saves about 200 ms so it doesn't seem like a very big win, but I could see some circumstances where maybe pytest, combined with other heavier plugins, may see a benefit from this.

JamesHutchison commented 1 year ago

Also, if this is taken on, check whether the pytest_load_initial_conftests hook gives similar performance and is usable, eliminating the need for this feature.

JamesHutchison commented 1 year ago

After some evaluation and measuring, my suspicion is that this is unnecessary with the existing logic. The reason is that we're now aborting earlier before plugins really get a chance to work. I suppose there might be a plugin that still adds overhead you may want to skip, but maybe it makes sense for something like that to come along.