ulwgl_test: update test for non-existent WINEPREFIX

- When the user sets a path to WINEPREFIX that doesn't exists, we should always create the directories and set the environment variable on their behalf.

- Related to 39b48b4c2c
This commit is contained in:
R1kaB3rN 2024-02-21 18:11:21 -08:00
parent 15b78b59c6
commit 6469e62b46
No known key found for this signature in database

View File

@ -1467,19 +1467,34 @@ class TestGameLauncher(unittest.TestCase):
def test_env_wine_dir(self): def test_env_wine_dir(self):
"""Test check_env when $WINEPREFIX is not a directory. """Test check_env when $WINEPREFIX is not a directory.
An error should not be raised if a WINEPREFIX is set but the path has not been created. When the user specifies a WINEPREFIX that doesn't exist, make the dirs on their behalf and set it
An error should not be raised in the process
""" """
# Set a path does not exist
os.environ["WINEPREFIX"] = "./foo" os.environ["WINEPREFIX"] = "./foo"
os.environ["GAMEID"] = self.test_file os.environ["GAMEID"] = self.test_file
os.environ["PROTONPATH"] = self.test_file os.environ["PROTONPATH"] = self.test_file
ulwgl_run.check_env(self.env)
self.assertEqual( self.assertFalse(
Path(os.environ["WINEPREFIX"]).is_dir(), Path(os.environ["WINEPREFIX"]).exists(),
True, "Expected WINEPREFIX to not exist before check_env",
"Expected WINEPREFIX to be created if not already exist",
) )
if Path(os.environ["WINEPREFIX"]).is_dir():
rmtree(os.environ["WINEPREFIX"]) ulwgl_run.check_env(self.env)
# After this, the WINEPREFIX and new dirs should be created for the user
self.assertTrue(
Path(self.env["WINEPREFIX"]).exists(),
"Expected WINEPREFIX to exist after check_env",
)
self.assertEqual(
self.env["WINEPREFIX"],
os.environ["WINEPREFIX"],
"Expected the WINEPREFIX to be set",
)
if Path(self.env["WINEPREFIX"]).is_dir():
Path(self.env["WINEPREFIX"]).rmdir()
def test_env_vars_paths(self): def test_env_vars_paths(self):
"""Test check_env when setting unexpanded paths for $WINEPREFIX and $PROTONPATH.""" """Test check_env when setting unexpanded paths for $WINEPREFIX and $PROTONPATH."""