File: test-exception-py3.py

package info (click to toggle)
dbus-python 1.4.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,708 kB
  • sloc: ansic: 9,653; python: 4,664; makefile: 597; sh: 428
file content (36 lines) | stat: -rwxr-xr-x 959 bytes parent folder | download | duplicates (2)
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()