Updated wrapper and tests

This commit is contained in:
Alexandru-Rudi Mățău 2020-04-26 19:42:38 +03:00
parent ab4a62ab2b
commit f6651bff34
6 changed files with 15 additions and 14 deletions

View file

@ -72,6 +72,8 @@ def log(line):
def main():
"""Runs a command independently from the Lutris client"""
# pylint: disable=too-many-branches,too-many-statements
# TODO: refactor
set_child_subreaper()
_, proc_title, include_proc_count, exclude_proc_count, *args = sys.argv
@ -224,7 +226,7 @@ def main():
if __name__ == "__main__":
LAUNCH_PATH = os.path.dirname(os.path.realpath(__file__))
if os.path.isdir(os.path.join(LAUNCH_PATH,"../lutris")):
if os.path.isdir(os.path.join(LAUNCH_PATH, "../lutris")):
logger.setLevel(logging.DEBUG)
sys.dont_write_bytecode = True
SOURCE_PATH = os.path.normpath(os.path.join(LAUNCH_PATH, '..'))

View file

@ -3,19 +3,19 @@ import os
import sys
import subprocess
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from lutris.util.wineregistry import WineRegistry
from lutris.util.wine.registry import WineRegistry
PREFIXES_PATH = os.path.expanduser("~/Games/wine/prefixes")
def get_registries():
registries = []
registry_list = []
directories = os.listdir(PREFIXES_PATH)
directories.append(os.path.expanduser("~/.wine"))
for prefix in directories:
for path in os.listdir(os.path.join(PREFIXES_PATH, prefix)):
if path.endswith(".reg"):
registries.append(os.path.join(PREFIXES_PATH, prefix, path))
return registries
registry_list.append(os.path.join(PREFIXES_PATH, prefix, path))
return registry_list
def check_registry(registry_path):
@ -23,11 +23,11 @@ def check_registry(registry_path):
original_content = registry_file.read()
try:
registry = WineRegistry(registry_path)
wine_registry = WineRegistry(registry_path)
except:
sys.stderr.write("Error parsing {}\n".format(registry_path))
raise
content = registry.render()
content = wine_registry.render()
if content != original_content:
wrong_path = os.path.join(os.path.dirname(__file__), 'error.reg')
with open(wrong_path, 'w') as wrong_reg:

View file

@ -43,4 +43,4 @@ class TestNvidiaGlxInfo(BaseGlxInfo):
self.assertEqual(self.glxinfo.opengl_version, "4.6.0 NVIDIA 415.25")
self.assertEqual(self.glxinfo.opengl_vendor, "NVIDIA Corporation")
with self.assertRaises(AttributeError):
self.glxinfo.GLX_MESA_query_renderer.version
self.glxinfo.GLX_MESA_query_renderer.version # pylint: disable=pointless-statement

View file

@ -58,10 +58,9 @@ class TestScriptInterpreter(TestCase):
self.assertEqual(params, "whatever")
def test_get_command_doesnt_return_private_methods(self):
""" """
interpreter = MockInterpreter(TEST_INSTALLER, None)
with self.assertRaises(ScriptingError) as ex:
command, params = interpreter._map_command(
interpreter._map_command(
{'_substitute': 'foo'}
)
self.assertEqual(ex.exception.message,

View file

@ -37,7 +37,7 @@ class LutrisWrapperTestCase(unittest.TestCase):
# Wait for the "Hello World" message that indicates that the process
# tree has started. This message arrives on stdout.
for line in wrapper_proc.stdout:
if b'Hello World' == line.strip():
if line.strip() == b'Hello World':
# We found the output we're looking for.
break
else:
@ -84,7 +84,7 @@ class LutrisWrapperTestCase(unittest.TestCase):
# Wait for the "Hello World" message that indicates that the process
# tree has started. This message arrives on stdout.
for line in wrapper_proc.stdout:
if b'Hello World' == line.strip():
if line.strip() == b'Hello World':
# We found the output we're looking for.
break
else:
@ -95,7 +95,7 @@ class LutrisWrapperTestCase(unittest.TestCase):
# Wait for confirmation that lutris-wrapper got our signal.
for line in wrapper_proc.stdout:
if b'--terminated processes--' == line.strip():
if line.strip() == b'--terminated processes--':
break
else:
self.fail("stdout EOF unexpectedly")

View file

@ -97,7 +97,7 @@ class TestWineRegistryKey(TestCase):
key = WineRegistryKey(path='Control Panel/Desktop')
self.assertEqual(key.name, 'Control Panel/Desktop')
self.assertEqual(key.raw_name, '[Control Panel\\\\Desktop]')
self.assertRegexpMatches(key.raw_timestamp, r'\d+\s\d+')
self.assertRegex(key.raw_timestamp, r'\d+\s\d+')
def test_parse_registry_key(self):
key = WineRegistryKey(path='Control Panel/Desktop')