From 8f823c7b6a44b751056604e31ccbfef3e601f559 Mon Sep 17 00:00:00 2001 From: Samuel FORESTIER Date: Sun, 14 Apr 2024 19:44:12 +0200 Subject: [PATCH] [DESKTOP_ENVIRONMENT] Fixes for Python < 3.8 `unittest.mock.mock_open` `__iter__` does not consume `read_data` before Python 3.8, causing tests to fail. --- archey/test/entries/test_archey_desktop_environment.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/archey/test/entries/test_archey_desktop_environment.py b/archey/test/entries/test_archey_desktop_environment.py index 03c6e605..b1c31328 100644 --- a/archey/test/entries/test_archey_desktop_environment.py +++ b/archey/test/entries/test_archey_desktop_environment.py @@ -125,8 +125,11 @@ def test_environment_detection_4(self, _) -> None: """ ), ) - def test_environment_detection_4_desktop_file(self, _) -> None: + def test_environment_detection_4_desktop_file(self, _mock_open) -> None: """_environment_detection against legacy `SESSION_DESKTOP` pointing to a desktop file""" + # Override `mock_open`'s __iter__ magic method for Python < 3.8 + _mock_open.__iter__ = iter(_mock_open.read_data.splitlines()) + self.assertEqual( DesktopEnvironment._environment_detection(), # pylint: disable=protected-access "Retro-Home",