Closed akhileshraju closed 4 years ago
Closing this issue because it's been inactive for two weeks - maybe try the pytest
tag on StackOverflow?
I have the same issue. After running pytest and finishes, it hangs indefinitely and not even Ctrl+c or Ctrl+z can kill the process.
I had to kill it on tests teardown as suggested by @akhileshraju by sending the kill signal to terminal.
It is worth mentioning that I am not using venv.
I am using:
The test setup that I have needs to connect to boards to be able to run tests. For this purpose, I wrote a package that makes use of
pexpect
to ssh into the machine the board is connected to and run some commands to make the board accessible to the test. I defined my ownpytest_collection_modifyitems
andpytest_unconfigure
in theconftests.py
asI start the test on the command line with
pytest
. The collection hook I defined is called, the test are executed, the pass/fail banner is printed and the last print "Released all boards to the barn" from my hook def is printed. But for some reason, pytest doesn't stop, unless I do ctrl+c. It stays stuck without releasing control. This happens on both Windows 10 and CentOS 7.4.I first ran this in PyCharm 2020.1 using their inbuilt test runner. In "Run" mode I see the same behavior i.e. the pytest session hangs after doing all the things. But in "Debug" mode (i.e. using the PyCharm debugger), the test session runs all hooks and tasks, prints the test results banner and exits with exit code
-1
, without any external intervention.To eliminate PyCharm as the source of the issue, I went to terminal (Linux) and cmd (Win), activated my venv and ran
pytest
in the tests folder and the tests hang.Even though the
--pdb
option is for tests, I was curious to see if I could use that to find out where pytest was getting stuck. But unfortunately didnt have any luck.Can someone please help with some pointers? Any ideas will be helpful. I have run out of ideas to debug this.
My venv has the following
For now, I hacked it by adding
os.kill(os.getpid(), signal.SIGTERM)
as the last statement in mypytest_unconfigure
hook. That gets pytest to stop, even though I don't like the solution.