diff --git a/qutebrowser/utils/version.py b/qutebrowser/utils/version.py index 7b44fed7e..4d0fd5146 100644 --- a/qutebrowser/utils/version.py +++ b/qutebrowser/utils/version.py @@ -59,7 +59,7 @@ Distribution = usertypes.enum( 'gentoo', 'fedora', 'opensuse', 'linuxmint', 'manjaro']) -def distribution(filename='/etc/os-release'): +def distribution(): """Get some information about the running Linux distribution. Returns: @@ -68,6 +68,7 @@ def distribution(filename='/etc/os-release'): version: A Version object, or None pretty: Always a string (might be "Unknown") """ + filename = os.environ.get('QUTE_FAKE_OS_RELEASE', '/etc/os-release') info = {} try: with open(filename, 'r', encoding='utf-8') as f: diff --git a/tests/unit/utils/test_version.py b/tests/unit/utils/test_version.py index 192ae92a7..b78f8798a 100644 --- a/tests/unit/utils/test_version.py +++ b/tests/unit/utils/test_version.py @@ -164,11 +164,13 @@ from qutebrowser.browser import pdfjs id='manjaro', parsed=version.Distribution.manjaro, version=None, pretty='Manjaro Linux')), ]) -def test_distribution(tmpdir, os_release, expected): +def test_distribution(tmpdir, monkeypatch, os_release, expected): os_release_file = tmpdir / 'os-release' if os_release is not None: os_release_file.write(textwrap.dedent(os_release)) - assert version.distribution(str(os_release_file)) == expected + monkeypatch.setenv('QUTE_FAKE_OS_RELEASE', str(os_release_file)) + + assert version.distribution() == expected class GitStrSubprocessFake: