Matoking/protontricks

Some tests are broken by pytest 8

Ancieg opened this issue · 1 comments

Describe the bug
Some tests are broken by pytest 8.
It seems that is related to logging (unexpected DEBUG level message).
Example:

_ TestSteamApp.test_steam_app_from_appmanifest_corrupted_toolmanifest[corrupted] _

self = <test_steam.TestSteamApp object at 0x7fe36cc21e80>
steam_runtime_soldier = <protontricks.steam.SteamApp object at 0x7fe36ceb1cc0>
proton_factory = <function proton_factory.<locals>.func at 0x7fe36cfcf1a0>
caplog = <_pytest.logging.LogCaptureFixture object at 0x7fe36cb31a30>
content = b'corrupted'

    @pytest.mark.parametrize(
        "content",
        [
            b"",  # Empty VDF is ignored
            b"corrupted",  # Can't be parsed as VDF
        ]
    )
    def test_steam_app_from_appmanifest_corrupted_toolmanifest(
            self, steam_runtime_soldier, proton_factory, caplog, content):
        """
        Test trying to a SteamApp manifest from an incomplete
        Proton installation with an empty or corrupted toolmanifest.vdf file
        """
        proton_app = proton_factory(
            name="Proton 5.13", appid=10, compat_tool_name="proton_513",
            required_tool_app=steam_runtime_soldier
        )
        # Empty the "toolmanifest.vdf" file
        (proton_app.install_path / "toolmanifest.vdf").write_bytes(content)

        assert not SteamApp.from_appmanifest(
            path=proton_app.install_path.parent.parent / "appmanifest_10.acf",
            steam_lib_paths=[]
        )

>       assert len(caplog.records) == 1
E       assert 5 == 1
E        +  where 5 = len([<LogRecord: protontricks, 10, /usr/src/RPM/BUILD/python3-module-protontricks-1.11.0/.run_venv/lib64/python3/site-packages/protontricks/steam.py, 509, "Loading appinfo.vdf in %s">, <LogRecord: protontricks, 10, /usr/src/RPM/BUILD/python3-module-protontricks-1.11.0/.run_venv/lib64/python3/site-packages/protontricks/steam.py, 526, "appinfo.vdf has magic number %s">, <LogRecord: protontricks, 10, /usr/src/RPM/BUILD/python3-module-protontricks-1.11.0/.run_venv/lib64/python3/site-packages/protontricks/steam.py, 196, "Creating SteamApp from manifest file in %s">, <LogRecord: protontricks, 10, /usr/src/RPM/BUILD/python3-module-protontricks-1.11.0/.run_venv/lib64/python3/site-packages/protontricks/steam.py, 805, "Found compatdata directories for app %s: %s">, <LogRecord: protontricks, 30, /usr/src/RPM/BUILD/python3-module-protontricks-1.11.0/.run_venv/lib64/python3/site-packages/protontricks/steam.py, 267, "Tool manifest for %s is empty or corrupted. You may need to reinstall the application.">])
E        +    where [<LogRecord: protontricks, 10, /usr/src/RPM/BUILD/python3-module-protontricks-1.11.0/.run_venv/lib64/python3/site-packages/protontricks/steam.py, 509, "Loading appinfo.vdf in %s">, <LogRecord: protontricks, 10, /usr/src/RPM/BUILD/python3-module-protontricks-1.11.0/.run_venv/lib64/python3/site-packages/protontricks/steam.py, 526, "appinfo.vdf has magic number %s">, <LogRecord: protontricks, 10, /usr/src/RPM/BUILD/python3-module-protontricks-1.11.0/.run_venv/lib64/python3/site-packages/protontricks/steam.py, 196, "Creating SteamApp from manifest file in %s">, <LogRecord: protontricks, 10, /usr/src/RPM/BUILD/python3-module-protontricks-1.11.0/.run_venv/lib64/python3/site-packages/protontricks/steam.py, 805, "Found compatdata directories for app %s: %s">, <LogRecord: protontricks, 30, /usr/src/RPM/BUILD/python3-module-protontricks-1.11.0/.run_venv/lib64/python3/site-packages/protontricks/steam.py, 267, "Tool manifest for %s is empty or corrupted. You may need to reinstall the application.">] = <_pytest.logging.LogCaptureFixture object at 0x7fe36cb31a30>.records

tests/test_steam.py:122: AssertionError
------------------------------ Captured log call -------------------------------
DEBUG    protontricks:steam.py:509 Loading appinfo.vdf in /usr/src/tmp/pytest-of-builder/pytest-0/test_steam_app_from_appmanifes7/home/fakeuser/.steam/steam/appcache/appinfo.vdf
DEBUG    protontricks:steam.py:526 appinfo.vdf has magic number b'(DV\x07'
DEBUG    protontricks:steam.py:196 Creating SteamApp from manifest file in /usr/src/tmp/pytest-of-builder/pytest-0/test_steam_app_from_appmanifes7/home/fakeuser/.steam/steam/steamapps/appmanifest_10.acf
DEBUG    protontricks:steam.py:805 Found compatdata directories for app 10: []
WARNING  protontricks:steam.py:267 Tool manifest for Proton 5.13 is empty or corrupted. You may need to reinstall the application.

To Reproduce
Run tests using pytest 8.

Expected behavior
A clear and concise description of what you expected to happen.

System (please complete the following information):

Additional context
Summary of broken tests (the same error: unexpected DEBUG level messages):

=========================== short test summary info ============================
FAILED tests/test_gui.py::TestSelectApp::test_select_game_locale_error - asse...
FAILED tests/test_gui.py::TestPromptFilesystemAccess::test_prompt_without_desktop
FAILED tests/test_gui.py::TestPromptFilesystemAccess::test_prompt_home_dir - ...
FAILED tests/test_steam.py::TestSteamApp::test_steam_app_from_appmanifest_corrupted_toolmanifest[]
FAILED tests/test_steam.py::TestSteamApp::test_steam_app_from_appmanifest_corrupted_toolmanifest[corrupted]
=================== 5 failed, 135 passed, 1 warning in 1.42s ===================

Should now be fixed in master as of bb1da5a. It should be possible to cherry pick that commit to fix downstream packages that were broken by the pytest update.