-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Cleanup code not executing in fixture #3409
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
GitMate.io thinks possibly related issues are #517 (setup_* executed before all fixtures), #832 (some codes are not executed.), #3032 (Teardown for parametrized module scope fixtures is not executed in the teardown phase), #1907 (Cleanup MANIFEST.in), and #1895 (Incorrect finalize/cleanup order of fixtures when using request.getfixturevalue()). |
i guess that you use a multiprocessing process then what you do is completely broken and cant possibly work, as you terminate he python process, if all you need is to run socat and terminate it, just use a subprocess.Popen object directly, |
Yes, I'm using Using |
i strongly suggest to do a socket connection based wait in the fixture after the popen call |
Maybe there’s a misunderstanding, but I’m not using socat for sockets, I’m using it for serial ports. |
thanks for pointing that out, i indeed missed the finer details of the cli args |
A try...finally clause might also help: @pytest.fixture
def socat():
proc = Process(target=socat_command)
proc.start()
try:
yield None
finally:
proc.terminate()
proc.join() |
I'm having a problem with things executing out of order in a fixture. I'm using
socat
to create a pair of virtual serial ports so that I can test some code that interacts with serial devices.socat
needs to be running the whole time the test is run, so I use a fixture to start it in a separate process. The issue is that if I don't wait at the beginning of the test the ports aren't open by the time the test runs. If I wait first, the test passes. In either case thesocat
process isn't terminated, even though I'm callingterminate
on the process. Here is the code:Why isn't the process terminated at the end? Is there a better way to do this? I want a fresh set of ports for each test so that the input/output buffers are always clean. I feel like this is just something I'm doing wrong or misunderstanding, so hopefully you can point me in the right direction.
These are the versions pinned in my
Pipfile.lock
:I'm on macOS 10.13.3.
The text was updated successfully, but these errors were encountered: