Blame test/test-exception-py3.py
|
Packit |
130fc8 |
#!/usr/bin/python
|
|
Packit |
130fc8 |
# -*- coding: utf-8 -*-
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
import unittest
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
import dbus
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
# from test-service.py
|
|
Packit |
130fc8 |
class ServiceError(dbus.DBusException):
|
|
Packit |
130fc8 |
"""Exception representing a normal "environmental" error"""
|
|
Packit |
130fc8 |
include_traceback = False
|
|
Packit |
130fc8 |
_dbus_error_name = 'com.example.Networking.ServerError'
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
class DBusExceptionTestCase(unittest.TestCase):
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
def test_dbus_exception(self):
|
|
Packit |
130fc8 |
e = dbus.exceptions.DBusException("bäää")
|
|
Packit |
130fc8 |
msg = e.get_dbus_message()
|
|
Packit |
130fc8 |
self.assertEqual(msg, "bäää")
|
|
Packit |
130fc8 |
self.assertEqual(str(e), "bäää")
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
def test_subclass_exception(self):
|
|
Packit |
130fc8 |
e = ServiceError("bäää")
|
|
Packit |
130fc8 |
msg = e.get_dbus_message()
|
|
Packit |
130fc8 |
self.assertEqual(msg, "bäää")
|
|
Packit |
130fc8 |
self.assertEqual(str(e), "com.example.Networking.ServerError: bäää")
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
if __name__ == "__main__":
|
|
Packit |
130fc8 |
unittest.main()
|