You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

42 lines
1.1 KiB

  1. # Just some helpers for test functions
  2. def myrepr(x):
  3. if isinstance(x, str):
  4. return '"' + x + '"'
  5. else:
  6. return repr(x)
  7. def eq_(a, b):
  8. if not a == b:
  9. raise AssertionError("%s != %s" % (myrepr(a), myrepr(b)))
  10. def lt_(a, b):
  11. if not a < b:
  12. raise AssertionError("%s is not less than %s" % (myrepr(a), myrepr(b)))
  13. def in_(a, b):
  14. if a not in b:
  15. raise AssertionError("%s not in %s" % (myrepr(a), myrepr(b)))
  16. def nin_(a, b):
  17. if a in b:
  18. raise AssertionError("unexpected %s in %s" % (myrepr(a), myrepr(b)))
  19. def in2_(a1, a2, b):
  20. if a1 not in b and a2 not in b:
  21. raise AssertionError("(%s or %s) not in %s" % (myrepr(a1), myrepr(a2),
  22. myrepr(b)))
  23. def ne_(a, b):
  24. if not a != b:
  25. raise AssertionError("unexpected %s == %s" % (myrepr(a), myrepr(b)))
  26. def lines_(a, n):
  27. l = a.count('\n')
  28. if not l == n:
  29. if len(a) > 5000:
  30. a = a[0:5000] + " ... truncated"
  31. raise AssertionError("wanted %d lines, got %d in output: '%s'"
  32. % (n, l, a))