File: test_client_against_native_bus.py

package info (click to toggle)
txdbus 1.1.0-9
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 996 kB
  • sloc: python: 6,658; makefile: 7
file content (35 lines) | stat: -rw-r--r-- 852 bytes parent folder | download | duplicates (3)
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
import os
import sys

import six

from twisted.trial import unittest

from tests import client_tests


# Only test against the native bus if it's available

if 'DBUS_SESSION_BUS_ADDRESS' in os.environ:
    orig_env = os.environ['DBUS_SESSION_BUS_ADDRESS']

    class NativeBusMixin (object):

        def _setup(self):
            os.environ['DBUS_SESSION_BUS_ADDRESS'] = orig_env

        def _teardown(self):
            pass

    # "Copy" the objects unit tests into this module
    m = sys.modules[__name__]

    for k, v in six.iteritems(client_tests.__dict__):
        if (
            isinstance(v, type) and
            issubclass(v, client_tests.ServerObjectTester) and
            v is not client_tests.ServerObjectTester
        ):
            setattr(m, k, type(
                k, (NativeBusMixin, v, unittest.TestCase), {}
            ))