D-Bus testing: removed side effect of TestDBusServerPresence tests

The TestDBusServerPresence tests have to invoke syncevo-dbus-server with
DBUS_TEST_CONNMAN set in the environment, to get it to use the mock
implementation on the session D-Bus.

They did this by modifying os.environment *permanently*. That had the
effect that all later tests also ended up using the mock ConnMan. This
made testing confusing because tests failed only when run in combination
with the presence tests (fixed previously by improving the mock ConnMan
implementation).

This commit addresses the root cause by putting the env variable only
temporarily into the environment of those tests which really need it.
This commit is contained in:
Patrick Ohly 2011-07-20 22:59:14 +08:00
parent de9eb60ab2
commit f21b829607

View file

@ -940,6 +940,7 @@ class TestDBusServerPresence(unittest.TestCase, DBusUtil):
self.conn.remove_from_connection()
self.conf = None
@property("ENV", "DBUS_TEST_CONNMAN=session")
@timeout(100)
def testPresenceSignal(self):
"""TestDBusServerPresence.testPresenceSignal - check Server.Presence signal"""
@ -1018,6 +1019,7 @@ class TestDBusServerPresence(unittest.TestCase, DBusUtil):
self.failUnlessEqual (self.bar, "")
match.remove()
@property("ENV", "DBUS_TEST_CONNMAN=session")
@timeout(100)
def testServerCheckPresence(self):
"""TestDBusServerPresence.testServerCheckPresence - check Server.CheckPresence()"""
@ -1061,6 +1063,7 @@ class TestDBusServerPresence(unittest.TestCase, DBusUtil):
self.failUnlessEqual (status, "")
self.failUnlessEqual (transports, ["obex-bt://bt-client-mixed"])
@property("ENV", "DBUS_TEST_CONNMAN=session")
@timeout(100)
def testSessionCheckPresence(self):
"""TestDBusServerPresence.testSessionCheckPresence - check Session.CheckPresence()"""
@ -1081,7 +1084,6 @@ class TestDBusServerPresence(unittest.TestCase, DBusUtil):
self.failUnlessEqual (status, "no transport")
def run(self, result):
os.environ["DBUS_TEST_CONNMAN"] = "session"
self.runTest(result, True)
class TestDBusSession(unittest.TestCase, DBusUtil):