图片解析应用
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.

31 lines
851 B

  1. from unittest import TestCase
  2. import pytest
  3. class ExceptionsTestCase(TestCase):
  4. def _get(self):
  5. from kazoo import exceptions
  6. return exceptions
  7. def test_backwards_alias(self):
  8. module = self._get()
  9. assert hasattr(module, "NoNodeException")
  10. assert module.NoNodeException is module.NoNodeError
  11. def test_exceptions_code(self):
  12. module = self._get()
  13. exc_8 = module.EXCEPTIONS[-8]
  14. assert isinstance(exc_8(), module.BadArgumentsError)
  15. def test_invalid_code(self):
  16. module = self._get()
  17. with pytest.raises(RuntimeError):
  18. module.EXCEPTIONS.__getitem__(666)
  19. def test_exceptions_construction(self):
  20. module = self._get()
  21. exc = module.EXCEPTIONS[-101]()
  22. assert type(exc) is module.NoNodeError
  23. assert exc.args == ()