2013-07-05 16:47:50 -04:00
|
|
|
# Just some helpers for test functions
|
|
|
|
|
|
|
|
def myrepr(x):
|
2020-08-03 16:54:33 -04:00
|
|
|
if isinstance(x, str):
|
2013-07-05 16:47:50 -04:00
|
|
|
return '"' + x + '"'
|
|
|
|
else:
|
|
|
|
return repr(x)
|
|
|
|
|
|
|
|
def eq_(a, b):
|
|
|
|
if not a == b:
|
|
|
|
raise AssertionError("%s != %s" % (myrepr(a), myrepr(b)))
|
|
|
|
|
|
|
|
def lt_(a, b):
|
|
|
|
if not a < b:
|
|
|
|
raise AssertionError("%s is not less than %s" % (myrepr(a), myrepr(b)))
|
|
|
|
|
|
|
|
def in_(a, b):
|
|
|
|
if a not in b:
|
|
|
|
raise AssertionError("%s not in %s" % (myrepr(a), myrepr(b)))
|
|
|
|
|
2013-07-05 21:58:30 -04:00
|
|
|
def nin_(a, b):
|
|
|
|
if a in b:
|
|
|
|
raise AssertionError("unexpected %s in %s" % (myrepr(a), myrepr(b)))
|
|
|
|
|
2013-07-05 16:47:50 -04:00
|
|
|
def in2_(a1, a2, b):
|
|
|
|
if a1 not in b and a2 not in b:
|
|
|
|
raise AssertionError("(%s or %s) not in %s" % (myrepr(a1), myrepr(a2),
|
|
|
|
myrepr(b)))
|
|
|
|
|
|
|
|
def ne_(a, b):
|
|
|
|
if not a != b:
|
|
|
|
raise AssertionError("unexpected %s == %s" % (myrepr(a), myrepr(b)))
|
|
|
|
|
|
|
|
def lines_(a, n):
|
|
|
|
l = a.count('\n')
|
|
|
|
if not l == n:
|
|
|
|
if len(a) > 5000:
|
|
|
|
a = a[0:5000] + " ... truncated"
|
|
|
|
raise AssertionError("wanted %d lines, got %d in output: '%s'"
|
|
|
|
% (n, l, a))
|
|
|
|
|