exit-code

Unit test script returns exit code = 0 even if tests fail

Unit test script returns exit code = 0 even if tests fail Question: My testing script looks as follows: import os import sys from unittest import defaultTestLoader as loader, TextTestRunner path_to_my_project = os.path.dirname(os.path.abspath(__file__)) + ‘/../’ sys.path.insert(0, path_to_my_project) suite = loader.discover(‘my_project’) runner = TextTestRunner() runner.run(suite) If I run this script, the output is: $ python3 runtest.py …

Total answers: 2

Difference between exit(0) and exit(1) in Python

Difference between exit(0) and exit(1) in Python Question: What’s the difference between exit(0) and exit(1) in Python? I tried looking around but didn’t find a specific question on these lines. If it’s already been answered, a link would be sufficient. Asked By: seeker || Source Answers: 0 and 1 are the exit codes. exit(0) means …

Total answers: 5

Setting exit code in Python when an exception is raised

Setting exit code in Python when an exception is raised Question: $ cat e.py raise Exception $ python e.py Traceback (most recent call last): File “e.py”, line 1, in <module> raise Exception Exception $ echo $? 1 I would like to change this exit code from 1 to 3 while still dumping the full stack …

Total answers: 1

Return value from thread

Return value from thread Question: How do I get a thread to return a tuple or any value of my choice back to the parent in Python? Asked By: pjay || Source Answers: Well, in the Python threading module, there are condition objects that are associated to locks. One method acquire() will return whatever value …

Total answers: 13

Exit codes in Python

Exit codes in Python Question: I got a message saying script xyz.py returned exit code 0. What does this mean? What do the exit codes in Python mean? How many are there? Which ones are important? Asked By: sundeep || Source Answers: Exit codes of 0 usually mean, “nothing wrong here.” However if the programmer …

Total answers: 14