Skip to content

Commit 804b71f

Browse files
committed
umu_test: update tests
- Replace references to UnixUser class
1 parent 5470ef7 commit 804b71f

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

umu/umu_test.py

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from unittest.mock import patch
1414
from pathlib import Path
1515
from shutil import rmtree, copytree, copy
16+
from pwd import getpwuid
1617

1718

1819
class TestGameLauncher(unittest.TestCase):
@@ -42,6 +43,7 @@ def setUp(self):
4243
"STORE": "",
4344
"PROTON_VERB": "",
4445
}
46+
self.user = getpwuid(os.getuid()).pw_name
4547
self.test_opts = "-foo -bar"
4648
# Proton verb
4749
# Used when testing build_command
@@ -1679,7 +1681,6 @@ def test_setup_pfx_symlinks_else(self):
16791681
"""
16801682
result = None
16811683
pattern = r"^/home/[\w\d]+"
1682-
user = umu_util.UnixUser()
16831684
unexpanded_path = re.sub(
16841685
pattern,
16851686
"~",
@@ -1695,7 +1696,7 @@ def test_setup_pfx_symlinks_else(self):
16951696

16961697
# Create the symlink to the test file itself
16971698
Path(unexpanded_path).joinpath("drive_c/users").joinpath(
1698-
user.get_user()
1699+
self.user
16991700
).expanduser().symlink_to(Path(self.test_file).absolute())
17001701
Path(unexpanded_path).joinpath("drive_c/users").joinpath(
17011702
"steamuser"
@@ -1716,7 +1717,6 @@ def test_setup_pfx_symlinks_unixuser(self):
17161717
"""
17171718
result = None
17181719
pattern = r"^/home/[\w\d]+"
1719-
user = umu_util.UnixUser()
17201720
unexpanded_path = re.sub(
17211721
pattern,
17221722
"~",
@@ -1727,7 +1727,7 @@ def test_setup_pfx_symlinks_unixuser(self):
17271727

17281728
# Create only the user dir
17291729
Path(unexpanded_path).joinpath("drive_c/users").joinpath(
1730-
user.get_user()
1730+
self.user
17311731
).expanduser().mkdir(parents=True, exist_ok=True)
17321732

17331733
result = umu_run.setup_pfx(unexpanded_path)
@@ -1745,7 +1745,7 @@ def test_setup_pfx_symlinks_unixuser(self):
17451745
)
17461746
self.assertEqual(
17471747
Path(self.test_file).joinpath("drive_c/users/steamuser").readlink(),
1748-
Path(user.get_user()),
1748+
Path(self.user),
17491749
"Expected steamuser -> user",
17501750
)
17511751

@@ -1755,7 +1755,6 @@ def test_setup_pfx_symlinks_steamuser(self):
17551755
Tests the case when only steamuser exist and the user dir does not exist
17561756
"""
17571757
result = None
1758-
user = umu_util.UnixUser()
17591758
pattern = r"^/home/[\w\d]+"
17601759
unexpanded_path = re.sub(
17611760
pattern,
@@ -1784,15 +1783,13 @@ def test_setup_pfx_symlinks_steamuser(self):
17841783
"Expected steamuser to be created",
17851784
)
17861785
self.assertTrue(
1787-
Path(unexpanded_path + "/drive_c/users/" + user.get_user())
1786+
Path(unexpanded_path + "/drive_c/users/" + self.user)
17881787
.expanduser()
17891788
.is_symlink(),
17901789
"Expected symbolic link for unixuser",
17911790
)
17921791
self.assertEqual(
1793-
Path(self.test_file)
1794-
.joinpath(f"drive_c/users/{user.get_user()}")
1795-
.readlink(),
1792+
Path(self.test_file).joinpath(f"drive_c/users/{self.user}").readlink(),
17961793
Path("steamuser"),
17971794
"Expected unixuser -> steamuser",
17981795
)
@@ -1876,7 +1873,6 @@ def test_setup_pfx_paths(self):
18761873
def test_setup_pfx(self):
18771874
"""Test setup_pfx."""
18781875
result = None
1879-
user = umu_util.UnixUser()
18801876
result = umu_run.setup_pfx(self.test_file)
18811877
self.assertIsNone(
18821878
result,
@@ -1896,7 +1892,7 @@ def test_setup_pfx(self):
18961892
"Expected steamuser to be created",
18971893
)
18981894
self.assertTrue(
1899-
Path(self.test_file + "/drive_c/users/" + user.get_user())
1895+
Path(self.test_file + "/drive_c/users/" + self.user)
19001896
.expanduser()
19011897
.is_symlink(),
19021898
"Expected symlink of username -> steamuser",

0 commit comments

Comments
 (0)