Skip to content
Snippets Groups Projects
Commit b92a8adb authored by Damien George's avatar Damien George
Browse files

tests: Add tests using "file" argument in print and sys.print_exception.

parent 582b1907
No related branches found
No related tags found
No related merge requests found
# test builtin print function, using file= argument
import sys
try:
sys.stdout
except AttributeError:
print('SKIP')
raise SystemExit
print(file=sys.stdout)
print('test', file=sys.stdout)
try:
print(file=1)
except (AttributeError, OSError): # CPython and uPy differ in error message
print('Error')
......@@ -56,3 +56,12 @@ try:
f()
except Exception as e:
print_exc(e)
# Test non-stream object passed as output object, only valid for uPy
if hasattr(sys, 'print_exception'):
try:
sys.print_exception(Exception, 1)
had_exception = False
except OSError:
had_exception = True
assert had_exception
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment