Commit c53eec69 authored by Michael Arntzenius's avatar Michael Arntzenius

fix tests to use "# should_error" or catch-and-print as appropriate

parent 30300d6c
# should_error
# Expected failure: even though we could copy the "definedness" information in the assignment,
# that's actually an error.
......
# should_error
# Expected failure: stacktrace testing
print 5 % 0
# should_error
not_defined
# should_error
# Expected failure: adding things that can't be added
1 + ""
# should_error
i = 0
i.a = 0
......@@ -15,4 +15,7 @@ print C.b
print C.a
print o.c
print o.b
print o.a # this should error
try:
print o.a
except AttributeError, e:
print e
# should_error
# This should raise a python level error, not an assertion in the compiler
x = 1
......
# This should raise a python level error, not an assertion in the compiler
print int.doesnt_exist
try:
print int.doesnt_exist
except AttributeError, e:
print e
......@@ -22,5 +22,11 @@ class C(object):
return self.n
print len(C(1))
print len(1)
print len(C("hello world"))
try:
print len(1)
except TypeError, e:
print e
try:
print len(C("hello world"))
except TypeError, e:
print e
# should_error
# Make sure that overriding __file__ doesn't change the traceback
# TODO the tester doesn't currently check the traceback
......
# should_error
class C(object):
pass
......
# should_error
def f():
if 0:
str = 0
......
# should_error
def msg():
print "msg()"
return "failure message"
......
......@@ -114,4 +114,7 @@ def f10():
# This should error: the lhs is evaluated first
x += [x for x in xrange(5)][0]
print x
f10()
try:
f10()
except UnboundLocalError, e:
print e
......@@ -9,5 +9,8 @@ def f():
# Augassigns can change the type of the variable:
i += IntLike()
print i
i + 1
try:
i + 1
except TypeError, e:
print e
f()
......@@ -4,4 +4,7 @@ print isinstance(3, basestring)
print basestring.__doc__
# should raise an exception
t = basestring.__new__(basestring)
try:
t = basestring.__new__(basestring)
except TypeError, e:
print e
......@@ -157,4 +157,7 @@ try:
except SystemError, e:
print e
print c.foo()
try:
print c.foo()
except SystemError, e:
print e
# should_error
# skip-if: sys.version_info < (2, 7, 4)
# - Error message changed in 2.7.4
......
......@@ -6,5 +6,7 @@ def bad_addr3(_x):
def g(y3):
return x3 + y3
return g
print bad_addr3(1)(2)
try:
print bad_addr3(1)(2)
except NameError, e:
print e
......@@ -5,4 +5,7 @@ def _escape():
if code:
return code
_escape()
try:
_escape()
except NameError, e:
print e
......@@ -34,8 +34,8 @@ C.ndd = 7
#TODO it would be nice to print these out (once __dict__ is implemented)
#print C.__dict__['dd']
#print C.__dict__['ndd']
print c.dd
print c.ndd
print C.dd
print C.ndd
# Repeat all of the above for subclasses of the descriptors
......
......@@ -4,4 +4,7 @@ def f():
# the del marks 'x' as a name written to in this scope
del x
print x
f()
try:
f()
except NameError, e:
print e
# should_error
class BadException(Exception):
def __str__(self):
print "str"
......@@ -7,7 +8,7 @@ try:
# This will raise:
print BadException()
assert 0
except NotImplementedError:
pass
except NotImplementedError, e:
print e
raise BadException()
......@@ -18,4 +18,7 @@ def f2(y):
return x
return y
print g2(f2(2))
try:
print g2(f2(2))
except NameError, e:
print e
# should_error
from __future__ import rvalue_references # should cause syntax error
# should_error
"docstring"
"not a docstring"
......
# should_error
"docstring"
def f():
......
......@@ -2,4 +2,7 @@ l = range(5)
print getattr(l, "pop")()
print getattr([], "a", "default")
print getattr([], "a")
try:
print getattr([], "a")
except AttributeError, e:
print e
# should_error
print getattr([], [])
......@@ -21,4 +21,7 @@ c = C()
c.__getitem__ = gi
print c[1]
print 1[1]
try:
print 1[1]
except TypeError, e:
print e
......@@ -4,7 +4,10 @@ def f():
print True # builtin, redefined
print False # builtin, not redefined
print z # local
print y # non-builtin, not defined
try:
print y # non-builtin, not defined
except NameError, e:
print e
x = 2
z = 2
......
# should_error
# As the test filename says, init functions must return None.
# This file tests that; it also makes sure that it gets tested
# when in a patchpoint.
......
......@@ -40,5 +40,7 @@ def f2(n, b):
f2(5, 0)
print i
f2(0, 1)
f2(0, 0)
try:
f2(0, 0)
except UnboundLocalError, e:
print e
# should_error
# skip-if: sys.version_info < (2, 7, 4)
# - Error message changed in 2.7.4
......
# should_error
class C(object):
return
......@@ -17,4 +17,7 @@ def si(k, v):
c.__setitem__ = si
c[3] = 4
1[2] = 3
try:
1[2] = 3
except TypeError, e:
print e
# should_error
# Different ways of nesting exceptions
import sys
......
# should_error
# Int not iterable:
a, b, c = 1
......@@ -17,4 +17,7 @@ class C(object):
def f(a, b, c):
print a, b, c
f(*C())
try:
f(*C())
except TypeError, e:
print e
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment