SHARE
TWEET

Untitled

a guest Sep 17th, 2019 88 in 143 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def assertIf(check, msg, exception):
  2.     if check:
  3.         raise exception(msg)
  4.  
  5. def assertIfNot(cond, msg, excpt = RuntimeError):
  6.     assertIf(not cond, msg, excpt)
  7.  
  8. def assertIsNone(val, msg, excpt = RuntimeError):
  9.     assertIf(val is None, msg, excpt)
  10.  
  11. def assertIn(val, collect, msg, excpt = RuntimeError):
  12.     assertIf(val in collect, msg, excpt)
  13.  
  14. def assertNotIn(val, collect, msg, excpt = RuntimeError):
  15.     assertIfNot(val in collect, msg, excpt)
  16.  
  17. def assertIsEmpty(collection: typing.Iterable, msg, excpt = RuntimeError):
  18.     """
  19.    Проверка пустых коллекций
  20.    """
  21.     assertIf(0 == len(collection), msg, excpt)
  22.  
  23. def assertIsNotInstance(var, obj, msg, excpt = RuntimeError):
  24.     assertIf(not isinstance(var, obj), msg, excpt)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top