pytest-flask icon indicating copy to clipboard operation
pytest-flask copied to clipboard

Live server subprocess

Open fuhrysteve opened this issue 9 years ago • 5 comments

Please don't merge this yet. There is still one test that is not passing for a mysterious reason, and additionally this code still needs test cases of its own.

I'm working on a way to launch flask as a completely separate process using os.fork by way of watcher_getter (from pytest-services).

The reason I need to use this strategy is that SQLAlchemy configurations become considerably more complex when you have to deal with multiprocessing (see docs). I was struggling to get it to work in my existing configuration, and this seemed like the easier option.

Let me know if you have any initial feedback and I'll circle back. Thanks @vitalk!

fuhrysteve avatar Jul 24 '16 12:07 fuhrysteve

Hi @fuhrysteve! This changes looks good for me. But live_server_subprocess fixture can be always available (not only when pytest-service is exists).

It would be great if live_server_subprocess fixture can detect missed requirements as well (such as flask>=0.11.0 or pytest-service) and skip tests with helpful message.

vitalk avatar Jul 24 '16 13:07 vitalk

Use the separate --start-live-server-subprocess option to run live_server fixture as subprocess is another suggestion. Any thoughts?

vitalk avatar Jul 24 '16 13:07 vitalk

@vitalk So I think the issue with always making live_server_subprocess always available is I'm not sure off the top of my head how to do that without making all tests fail at collection time - the reason is that watcher_getter would fail because it says it can't find a fixture with that name.

So I'm not sure how to make it optionally available unless there's some way I'm not aware of to get a fixture at runtime.

Any suggestions?

fuhrysteve avatar Jul 24 '16 13:07 fuhrysteve

@vitalk with regards to --start-live-server-subprocess, sounds like a good idea to me - i'll add it in.

fuhrysteve avatar Jul 24 '16 13:07 fuhrysteve

the reason is that watcher_getter would fail because it says it can't find a fixture with that name

I missed that part, maybe I can find a workaround.

vitalk avatar Jul 24 '16 14:07 vitalk