Browse Source

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

pull/3885/head
Damien George 6 years ago
parent
commit
b92a8adbfa
  1. 17
      tests/io/builtin_print_file.py
  2. 9
      tests/misc/print_exception.py

17
tests/io/builtin_print_file.py

@ -0,0 +1,17 @@
# 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')

9
tests/misc/print_exception.py

@ -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

Loading…
Cancel
Save