Skip to content

Commit

Permalink
[DESKTOP_ENVIRONMENT] Fixes for Python < 3.8 unittest.mock.mock_open
Browse files Browse the repository at this point in the history
`__iter__` does not consume `read_data` before Python 3.8, causing tests
to fail.
  • Loading branch information
HorlogeSkynet committed Apr 20, 2024
1 parent 18e7098 commit 8f823c7
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion archey/test/entries/test_archey_desktop_environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 8f823c7

Please sign in to comment.