I want to check what the function performs os._exit(2)on error. I have seen many solutions with sys.exit()using SystemExit. I read both Python3 and Python2 and it seems that it is os._exit()not usingSystemExit
os._exit(2)
sys.exit()
SystemExit
os._exit()
However, I tried this in case it was a misunderstanding of the documentation on my side, but it just comes out of the net test, this is not even a test error:
make: *** [test] Error 2
This is probably due to the call function os._exit(2)
os.system() 8 , script :
os.system()
import os assert os.system('python script.py') >> 8 == 2
os._exit() sys.exit():
import os, sys import script os._exit = sys.exit script.tested_method() # raises SystemExit
unittest.mock.MagicMock , .
unittest.mock.MagicMock
from unittest import mock import os def funcToTest(): os.exit(2) def test_func(): os._exit = mock.MagicMock() funcToTest() assert os._exit.called
Source: https://habr.com/ru/post/1681766/More articles:Creating a task that runs before all other tasks in gradle - gradleImplement Keras in LSTMCell (the class uses additional peep-hole connections, additional cell cut-off and additional projection layer). - cellGoogle Sign In error Status {statusCode = DEVELOPER_ERROR, resolution = null} from the same play store application not from the same signed apk - androidНе удалось прочитать документ схемы: classpath: spring - beans -3.1.xsd ' - xmlDoes DirectoryInfo.ToString work differently in parent directories? - c #Attach two lists of offsets ("zip offset"?) - pythonSwift SceneKit - get camera direction - swiftIn C, is it guaranteed that the starting address of the array is less than the addresses of other elements? - cHow can I add the OpenCV library to my reaction project? - androidНе удалось получить неизвестное свойство 'outputFile' для задачи ': app: packageDebug' - androidAll Articles