From 6469e62b46bd31609536c151465f46eee4468380 Mon Sep 17 00:00:00 2001 From: R1kaB3rN <100738684+R1kaB3rN@users.noreply.github.com> Date: Wed, 21 Feb 2024 18:11:21 -0800 Subject: [PATCH] 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 https://github.com/Open-Wine-Components/ULWGL-launcher/commit/39b48b4c2c0ae072795c54e9164be4393f3b796d --- ulwgl_test.py | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/ulwgl_test.py b/ulwgl_test.py index b87f50f..6b07483 100644 --- a/ulwgl_test.py +++ b/ulwgl_test.py @@ -1467,19 +1467,34 @@ class TestGameLauncher(unittest.TestCase): def test_env_wine_dir(self): """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["GAMEID"] = self.test_file os.environ["PROTONPATH"] = self.test_file - ulwgl_run.check_env(self.env) - self.assertEqual( - Path(os.environ["WINEPREFIX"]).is_dir(), - True, - "Expected WINEPREFIX to be created if not already exist", + + self.assertFalse( + Path(os.environ["WINEPREFIX"]).exists(), + "Expected WINEPREFIX to not exist before check_env", ) - 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): """Test check_env when setting unexpanded paths for $WINEPREFIX and $PROTONPATH."""