From b3d19cb25a6b6f1c1d6614ef69e8eed143c4d2ee Mon Sep 17 00:00:00 2001 From: Vladimir Slavik Date: May 25 2020 19:18:30 +0000 Subject: Fix test to not use Python 3.8 feature Returning the mock dictionary for context is a Python 3.8 feature. Also silence the warnings that this is an usafe operation, it is a mock now. --- diff --git a/tests/nosetests/pyanaconda_tests/dbus_test.py b/tests/nosetests/pyanaconda_tests/dbus_test.py index 69b6d78..e9ef9d2 100644 --- a/tests/nosetests/pyanaconda_tests/dbus_test.py +++ b/tests/nosetests/pyanaconda_tests/dbus_test.py @@ -17,6 +17,7 @@ # # Red Hat Author(s): Vendula Poncova # +import os import tempfile import unittest from unittest.mock import patch @@ -57,8 +58,8 @@ class AnacondaDBusConnectionTestCase(unittest.TestCase): with patch("pyanaconda.core.dbus.ANACONDA_BUS_ADDR_FILE", f.name): self._check_addressed_connection(message_bus, getter, "ADDRESS") - with patch.dict("os.environ") as environment: - environment[DBUS_ANACONDA_SESSION_ADDRESS] = "ADDRESS" + with patch.dict("os.environ"): + os.environ[DBUS_ANACONDA_SESSION_ADDRESS] = "ADDRESS" # pylint: disable=environment-modify self._check_addressed_connection(message_bus, getter, "ADDRESS") @patch("dasbus.connection.Gio.DBusConnection.new_for_address_sync") @@ -72,8 +73,8 @@ class AnacondaDBusConnectionTestCase(unittest.TestCase): """Test the default bus.""" message_bus = DefaultMessageBus() - with patch.dict("os.environ") as environment: - environment[DBUS_STARTER_ADDRESS] = "ADDRESS" + with patch.dict("os.environ"): + os.environ[DBUS_STARTER_ADDRESS] = "ADDRESS" # pylint: disable=environment-modify self._check_addressed_connection(message_bus, getter, "ADDRESS") self._check_anaconda_connection(message_bus, getter)