Python 单元测试失败,出现退出代码 138 和空套件错误
Python unit test fails with Exit Code 138 & Empty suite errors
我能够 运行 这个 Python 直接从 IntelliJ 测试:
from unittest import TestCase
class TestDebug(TestCase):
def test_debug(self):
print("test")
输出:
/Users/work/dev/venv/bin/python3 "/Users/work/Library/Application Support/JetBrains/Toolbox/apps/IDEA-U/ch-0/213.5744.223/IntelliJ IDEA.app.plugins/python/helpers/pycharm/_jb_unittest_runner.py" --target test_debug.TestDebug
Testing started at 9:45 AM ...
Launching unittests with arguments python -m unittest test_debug.TestDebug in /Users/work/dev/tests
Ran 1 test in 0.001s
OK
Process finished with exit code 0
test
但是,当 运行在调试模式下运行它时,它会失败并显示以下输出:
/Users/work/dev/venv/bin/python3 "/Users/work/Library/Application Support/JetBrains/Toolbox/apps/IDEA-U/ch-0/213.5744.223/IntelliJ IDEA.app.plugins/python/helpers/pydev/pydevd.py" --multiproc --qt-support=auto --client 127.0.0.1 --port 57545 --file "/Users/work/Library/Application Support/JetBrains/Toolbox/apps/IDEA-U/ch-0/213.5744.223/IntelliJ IDEA.app.plugins/python/helpers/pycharm/_jb_unittest_runner.py" --target test_debug.TestDebug
Testing started at 9:45 AM ...
Connected to pydev debugger (build 213.5744.223)
Process finished with exit code 138 (interrupted by signal 10: SIGBUS)
Empty suite
Empty suite
感谢任何帮助!
这似乎是由 Cython issue 引起的。您可以通过在 run/debug 配置或您的环境中设置以下内容来解决此问题:
PYDEVD_USE_CYTHON=NO
PYDEVD_USE_FRAME_EVAL=NO
我能够 运行 这个 Python 直接从 IntelliJ 测试:
from unittest import TestCase
class TestDebug(TestCase):
def test_debug(self):
print("test")
输出:
/Users/work/dev/venv/bin/python3 "/Users/work/Library/Application Support/JetBrains/Toolbox/apps/IDEA-U/ch-0/213.5744.223/IntelliJ IDEA.app.plugins/python/helpers/pycharm/_jb_unittest_runner.py" --target test_debug.TestDebug
Testing started at 9:45 AM ...
Launching unittests with arguments python -m unittest test_debug.TestDebug in /Users/work/dev/tests
Ran 1 test in 0.001s
OK
Process finished with exit code 0
test
但是,当 运行在调试模式下运行它时,它会失败并显示以下输出:
/Users/work/dev/venv/bin/python3 "/Users/work/Library/Application Support/JetBrains/Toolbox/apps/IDEA-U/ch-0/213.5744.223/IntelliJ IDEA.app.plugins/python/helpers/pydev/pydevd.py" --multiproc --qt-support=auto --client 127.0.0.1 --port 57545 --file "/Users/work/Library/Application Support/JetBrains/Toolbox/apps/IDEA-U/ch-0/213.5744.223/IntelliJ IDEA.app.plugins/python/helpers/pycharm/_jb_unittest_runner.py" --target test_debug.TestDebug
Testing started at 9:45 AM ...
Connected to pydev debugger (build 213.5744.223)
Process finished with exit code 138 (interrupted by signal 10: SIGBUS)
Empty suite
Empty suite
感谢任何帮助!
这似乎是由 Cython issue 引起的。您可以通过在 run/debug 配置或您的环境中设置以下内容来解决此问题:
PYDEVD_USE_CYTHON=NO
PYDEVD_USE_FRAME_EVAL=NO