1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
|
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Copyright 2012 Michael Vogt
# Copyright 2016-2020 Collabora Ltd.
# SPDX-License-Identifier: MIT
import unittest
import dbus
import dbus_test_utils
# from test-service.py
class ServiceError(dbus.DBusException):
"""Exception representing a normal "environmental" error"""
include_traceback = False
_dbus_error_name = 'com.example.Networking.ServerError'
class DBusExceptionTestCase(unittest.TestCase):
def test_dbus_exception(self):
e = dbus.exceptions.DBusException("bäää")
msg = e.get_dbus_message()
self.assertEqual(msg, "bäää")
self.assertEqual(str(e), "bäää")
def test_subclass_exception(self):
e = ServiceError("bäää")
msg = e.get_dbus_message()
self.assertEqual(msg, "bäää")
self.assertEqual(str(e), "com.example.Networking.ServerError: bäää")
if __name__ == "__main__":
dbus_test_utils.main()
|