# Path: dbusmock/mockobject.py
# MOCK_IFACE = 'org.freedesktop.DBus.Mock'
# 
# OBJECT_MANAGER_IFACE = 'org.freedesktop.DBus.ObjectManager'
# 
# def load_module(name: str):
#     '''Load a mock template Python module from dbusmock/templates/'''
# 
#     if os.path.exists(name) and os.path.splitext(name)[1] == '.py':
#         spec = importlib.util.spec_from_file_location(os.path.splitext(os.path.basename(name))[0], name)
#         assert spec
#         mod = importlib.util.module_from_spec(spec)
#         with open(name, encoding="UTF-8") as f:
#             exec(f.read(), mod.__dict__, mod.__dict__)  # pylint: disable=exec-used
#         return mod
# 
#     return importlib.import_module('dbusmock.templates.' + name)


import errno
import os
import signal
import subprocess
import sys
import tempfile
import time
import unittest
import dbus
from typing import Tuple, Dict, Any
from dbusmock.mockobject import MOCK_IFACE, OBJECT_MANAGER_IFACE, load_module

        This function blocks until the spawned DBusMockObject is ready and
        listening on the bus.

        Returns a pair (daemon Popen object, main dbus object).
        '''
        # we need the bus address from the template module
        module = load_module(template)

        if hasattr(module, 'IS_OBJECT_MANAGER'):
            is_object_manager = module.IS_OBJECT_MANAGER
        else:
            is_object_manager = False

        if is_object_manager and not hasattr(module, 'MAIN_IFACE'):
            interface_name = OBJECT_MANAGER_IFACE
        else:
            interface_name = module.MAIN_IFACE

        if system_bus is None:
            system_bus = module.SYSTEM_BUS

        daemon = cls.spawn_server(module.BUS_NAME, module.MAIN_OBJ,
                                  interface_name, system_bus, stdout)

        bus = cls.get_dbus(system_bus)
        obj = bus.get_object(module.BUS_NAME, module.MAIN_OBJ)
        if not parameters:
            parameters = dbus.Dictionary({}, signature='sv')
        obj.AddTemplate(template, parameters,

# Path: dbusmock/mockobject.py
# MOCK_IFACE = 'org.freedesktop.DBus.Mock'
# 
# OBJECT_MANAGER_IFACE = 'org.freedesktop.DBus.ObjectManager'
# 
# def load_module(name: str):
#     '''Load a mock template Python module from dbusmock/templates/'''
# 
#     if os.path.exists(name) and os.path.splitext(name)[1] == '.py':
#         spec = importlib.util.spec_from_file_location(os.path.splitext(os.path.basename(name))[0], name)
#         assert spec
#         mod = importlib.util.module_from_spec(spec)
#         with open(name, encoding="UTF-8") as f:
#             exec(f.read(), mod.__dict__, mod.__dict__)  # pylint: disable=exec-used
#         return mod
# 
#     return importlib.import_module('dbusmock.templates.' + name)


# Path: dbusmock/testcase.py
import errno
import os
import signal
import subprocess
import sys
import tempfile
import time
import unittest
import dbus
from typing import Tuple, Dict, Any
from dbusmock.mockobject import MOCK_IFACE, OBJECT_MANAGER_IFACE, load_module


        This function blocks until the spawned DBusMockObject is ready and
        listening on the bus.

        Returns a pair (daemon Popen object, main dbus object).
        '''
        # we need the bus address from the template module
        module = load_module(template)

        if hasattr(module, 'IS_OBJECT_MANAGER'):
            is_object_manager = module.IS_OBJECT_MANAGER
        else:
            is_object_manager = False

        if is_object_manager and not hasattr(module, 'MAIN_IFACE'):
            interface_name = OBJECT_MANAGER_IFACE
        else:
            interface_name = module.MAIN_IFACE

        if system_bus is None:
            system_bus = module.SYSTEM_BUS

        daemon = cls.spawn_server(module.BUS_NAME, module.MAIN_OBJ,
                                  interface_name, system_bus, stdout)

        bus = cls.get_dbus(system_bus)
        obj = bus.get_object(module.BUS_NAME, module.MAIN_OBJ)
        if not parameters:
            parameters = dbus.Dictionary({}, signature='sv')
        obj.AddTemplate(template, parameters,

                        dbus_interface=MOCK_IFACE)