Communicate between python and pytest.main() #8766
Unanswered
AndrewFalanga
asked this question in
Q&A
Replies: 1 comment
-
The plugins parameter of main can be used to pass in a plugin object |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Are there any suggestions for how someone might effectively communicate between python and
pytest.main()
. I'm using a python daemon to execute tests viapytest.main()
. The caching issue shouldn't be a problem because the test files won't be changing invocations. However, there is a need for rebooting the system on which the test is executing. I already have a method logging the progress through the session, suspending the session, and restoring when the session is resumed. The problem now is that the test cases will be requesting the reboot. When that takes place, I need to communicate back to the daemon that the session requested the reboot and it must gracefully exit.I've played around with various methods and none have proven too effective. Might this be a case for a pipe? I could open a pipe in the main python process and then pass the pipe into a plugin. The plugin could, in theory, notify the main process that the reboot is coming.
Another possibility is using shared memory. This seems to mean some sort of fancy use of
multiprocessing
. I haven't done much experimentation with that yet.Another thought, is it possible to extend the exit codes of pytest?
It seems that
pytest.main()
is a subprocess rather than a thread. I first played with simply using global variables, but this does not work. Neither did using environment variables. This leads me to believe thatpytest.main()
spawns a subprocess.Beta Was this translation helpful? Give feedback.
All reactions