13
13
from unittest .mock import patch
14
14
from pathlib import Path
15
15
from shutil import rmtree , copytree , copy
16
+ from pwd import getpwuid
16
17
17
18
18
19
class TestGameLauncher (unittest .TestCase ):
@@ -42,6 +43,7 @@ def setUp(self):
42
43
"STORE" : "" ,
43
44
"PROTON_VERB" : "" ,
44
45
}
46
+ self .user = getpwuid (os .getuid ()).pw_name
45
47
self .test_opts = "-foo -bar"
46
48
# Proton verb
47
49
# Used when testing build_command
@@ -1679,7 +1681,6 @@ def test_setup_pfx_symlinks_else(self):
1679
1681
"""
1680
1682
result = None
1681
1683
pattern = r"^/home/[\w\d]+"
1682
- user = umu_util .UnixUser ()
1683
1684
unexpanded_path = re .sub (
1684
1685
pattern ,
1685
1686
"~" ,
@@ -1695,7 +1696,7 @@ def test_setup_pfx_symlinks_else(self):
1695
1696
1696
1697
# Create the symlink to the test file itself
1697
1698
Path (unexpanded_path ).joinpath ("drive_c/users" ).joinpath (
1698
- user . get_user ()
1699
+ self . user
1699
1700
).expanduser ().symlink_to (Path (self .test_file ).absolute ())
1700
1701
Path (unexpanded_path ).joinpath ("drive_c/users" ).joinpath (
1701
1702
"steamuser"
@@ -1716,7 +1717,6 @@ def test_setup_pfx_symlinks_unixuser(self):
1716
1717
"""
1717
1718
result = None
1718
1719
pattern = r"^/home/[\w\d]+"
1719
- user = umu_util .UnixUser ()
1720
1720
unexpanded_path = re .sub (
1721
1721
pattern ,
1722
1722
"~" ,
@@ -1727,7 +1727,7 @@ def test_setup_pfx_symlinks_unixuser(self):
1727
1727
1728
1728
# Create only the user dir
1729
1729
Path (unexpanded_path ).joinpath ("drive_c/users" ).joinpath (
1730
- user . get_user ()
1730
+ self . user
1731
1731
).expanduser ().mkdir (parents = True , exist_ok = True )
1732
1732
1733
1733
result = umu_run .setup_pfx (unexpanded_path )
@@ -1745,7 +1745,7 @@ def test_setup_pfx_symlinks_unixuser(self):
1745
1745
)
1746
1746
self .assertEqual (
1747
1747
Path (self .test_file ).joinpath ("drive_c/users/steamuser" ).readlink (),
1748
- Path (user . get_user () ),
1748
+ Path (self . user ),
1749
1749
"Expected steamuser -> user" ,
1750
1750
)
1751
1751
@@ -1755,7 +1755,6 @@ def test_setup_pfx_symlinks_steamuser(self):
1755
1755
Tests the case when only steamuser exist and the user dir does not exist
1756
1756
"""
1757
1757
result = None
1758
- user = umu_util .UnixUser ()
1759
1758
pattern = r"^/home/[\w\d]+"
1760
1759
unexpanded_path = re .sub (
1761
1760
pattern ,
@@ -1784,15 +1783,13 @@ def test_setup_pfx_symlinks_steamuser(self):
1784
1783
"Expected steamuser to be created" ,
1785
1784
)
1786
1785
self .assertTrue (
1787
- Path (unexpanded_path + "/drive_c/users/" + user . get_user () )
1786
+ Path (unexpanded_path + "/drive_c/users/" + self . user )
1788
1787
.expanduser ()
1789
1788
.is_symlink (),
1790
1789
"Expected symbolic link for unixuser" ,
1791
1790
)
1792
1791
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 (),
1796
1793
Path ("steamuser" ),
1797
1794
"Expected unixuser -> steamuser" ,
1798
1795
)
@@ -1876,7 +1873,6 @@ def test_setup_pfx_paths(self):
1876
1873
def test_setup_pfx (self ):
1877
1874
"""Test setup_pfx."""
1878
1875
result = None
1879
- user = umu_util .UnixUser ()
1880
1876
result = umu_run .setup_pfx (self .test_file )
1881
1877
self .assertIsNone (
1882
1878
result ,
@@ -1896,7 +1892,7 @@ def test_setup_pfx(self):
1896
1892
"Expected steamuser to be created" ,
1897
1893
)
1898
1894
self .assertTrue (
1899
- Path (self .test_file + "/drive_c/users/" + user . get_user () )
1895
+ Path (self .test_file + "/drive_c/users/" + self . user )
1900
1896
.expanduser ()
1901
1897
.is_symlink (),
1902
1898
"Expected symlink of username -> steamuser" ,
0 commit comments