mirror of
https://github.com/tcsenpai/UWINE.git
synced 2025-06-07 12:05:21 +00:00
ulwgl_test: update test when interrupting cache extraction
- Removes assertions that check for state of variables when an error is raised and updates comments
This commit is contained in:
parent
63fba6c892
commit
dfa8f975db
@ -104,10 +104,13 @@ class TestGameLauncher(unittest.TestCase):
|
|||||||
"""Test _get_from_cache on keyboard interrupt."""
|
"""Test _get_from_cache on keyboard interrupt."""
|
||||||
result = None
|
result = None
|
||||||
# In the real usage, should be populated after successful callout for latest Proton releases
|
# In the real usage, should be populated after successful callout for latest Proton releases
|
||||||
|
|
||||||
|
def test_cache_interrupt(self):
|
||||||
|
"""Test _get_from_cache on keyboard interrupt on extraction from the cache to the compat dir."""
|
||||||
|
# In the real usage, should be populated after successful callout for latest Proton releases
|
||||||
# Just mock it and assumes its the latest
|
# Just mock it and assumes its the latest
|
||||||
files = [("", ""), (self.test_archive.name, "")]
|
files = [("", ""), (self.test_archive.name, "")]
|
||||||
|
|
||||||
# Populate the Steam compat dir by extracting the tarball
|
|
||||||
ulwgl_dl_util._extract_dir(self.test_archive, self.test_compat)
|
ulwgl_dl_util._extract_dir(self.test_archive, self.test_compat)
|
||||||
|
|
||||||
self.assertTrue(
|
self.assertTrue(
|
||||||
@ -120,17 +123,15 @@ class TestGameLauncher(unittest.TestCase):
|
|||||||
with patch("ulwgl_dl_util._extract_dir") as mock_function:
|
with patch("ulwgl_dl_util._extract_dir") as mock_function:
|
||||||
with self.assertRaisesRegex(KeyboardInterrupt, ""):
|
with self.assertRaisesRegex(KeyboardInterrupt, ""):
|
||||||
# Mock the interrupt
|
# Mock the interrupt
|
||||||
|
# We want to simulate an interrupt mid-extraction in this case
|
||||||
# We want the dir we tried to extract to be cleaned
|
# We want the dir we tried to extract to be cleaned
|
||||||
mock_function.side_effect = KeyboardInterrupt
|
mock_function.side_effect = KeyboardInterrupt
|
||||||
result = ulwgl_dl_util._get_from_cache(
|
ulwgl_dl_util._get_from_cache(
|
||||||
self.env, self.test_compat, self.test_cache, files, True
|
self.env, self.test_compat, self.test_cache, files, True
|
||||||
)
|
)
|
||||||
|
|
||||||
self.assertFalse(result, "Expected None on keyboard interrupt")
|
# After interrupt, we attempt to clean the compat dir for the file we tried to extract because it could be in an incomplete state
|
||||||
self.assertFalse(
|
# Verify that the dir we tried to extract from cache is removed to avoid corruption on next launch
|
||||||
self.env["PROTONPATH"],
|
|
||||||
"Expected PROTONPATH to be empty when the cache is empty",
|
|
||||||
)
|
|
||||||
self.assertFalse(
|
self.assertFalse(
|
||||||
self.test_compat.joinpath(
|
self.test_compat.joinpath(
|
||||||
self.test_archive.name[: self.test_archive.name.find(".tar.gz")]
|
self.test_archive.name[: self.test_archive.name.find(".tar.gz")]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user