Merge pull request #5296 from microDev1/traceback

Add test for `traceback` module
This commit is contained in:
Mark 2021-09-03 12:43:40 -05:00 committed by GitHub
commit 69e7b8bb79
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 25 additions and 0 deletions

View File

@ -0,0 +1,25 @@
try:
import traceback
except ImportError:
print("SKIP")
raise SystemExit
def fun():
raise Exception("test")
try:
fun()
except Exception as exc:
print("\nNo Trace:")
traceback.print_exception(None, exc, None)
print("\nDefault Trace:")
traceback.print_exception(None, exc, exc.__traceback__)
print("\nLimit=1 Trace:")
traceback.print_exception(None, exc, exc.__traceback__, limit=1)
print("\nLimit=0 Trace:")
traceback.print_exception(None, exc, exc.__traceback__, limit=0)
print("\nLimit=-1 Trace:")
traceback.print_exception(None, exc, exc.__traceback__, limit=-1)
print("")