2012-03-29 17:43:05 -04:00
|
|
|
# Just some helpers for test functions
|
|
|
|
|
|
|
|
import shutil, os
|
|
|
|
|
2012-04-04 18:34:01 -04:00
|
|
|
def myrepr(x):
|
|
|
|
if isinstance(x, basestring):
|
|
|
|
return '"' + x + '"'
|
|
|
|
else:
|
|
|
|
return repr(x)
|
|
|
|
|
2012-03-29 17:43:05 -04:00
|
|
|
def eq_(a, b):
|
|
|
|
if not a == b:
|
2012-04-04 18:34:01 -04:00
|
|
|
raise AssertionError("%s != %s" % (myrepr(a), myrepr(b)))
|
2012-03-29 17:43:05 -04:00
|
|
|
|
|
|
|
def in_(a, b):
|
|
|
|
if a not in b:
|
2012-04-04 18:34:01 -04:00
|
|
|
raise AssertionError("%s not in %s" % (myrepr(a), myrepr(b)))
|
2012-03-29 17:43:05 -04:00
|
|
|
|
|
|
|
def ne_(a, b):
|
|
|
|
if not a != b:
|
2012-04-04 18:34:01 -04:00
|
|
|
raise AssertionError("unexpected %s == %s" % (myrepr(a), myrepr(b)))
|
2012-03-29 17:43:05 -04:00
|
|
|
|
2012-12-11 23:31:55 -05:00
|
|
|
def lines_(a, n):
|
2012-12-12 19:25:27 -05:00
|
|
|
l = a.count('\n')
|
|
|
|
if not l == n:
|
|
|
|
raise AssertionError("wanted %d lines, got %d in output: '%s'"
|
|
|
|
% (n, l, a))
|
2012-12-11 23:31:55 -05:00
|
|
|
|
2012-03-29 17:43:05 -04:00
|
|
|
def recursive_unlink(path):
|
|
|
|
try:
|
|
|
|
shutil.rmtree(path)
|
|
|
|
except OSError:
|
|
|
|
pass
|
|
|
|
try:
|
|
|
|
os.unlink(path)
|
|
|
|
except OSError:
|
|
|
|
pass
|
|
|
|
|