Add QUTE_FAKE_OS_RELEASE envvar
This commit is contained in:
parent
ef504e5b25
commit
4cb82af11e
@ -59,7 +59,7 @@ Distribution = usertypes.enum(
|
|||||||
'gentoo', 'fedora', 'opensuse', 'linuxmint', 'manjaro'])
|
'gentoo', 'fedora', 'opensuse', 'linuxmint', 'manjaro'])
|
||||||
|
|
||||||
|
|
||||||
def distribution(filename='/etc/os-release'):
|
def distribution():
|
||||||
"""Get some information about the running Linux distribution.
|
"""Get some information about the running Linux distribution.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
@ -68,6 +68,7 @@ def distribution(filename='/etc/os-release'):
|
|||||||
version: A Version object, or None
|
version: A Version object, or None
|
||||||
pretty: Always a string (might be "Unknown")
|
pretty: Always a string (might be "Unknown")
|
||||||
"""
|
"""
|
||||||
|
filename = os.environ.get('QUTE_FAKE_OS_RELEASE', '/etc/os-release')
|
||||||
info = {}
|
info = {}
|
||||||
try:
|
try:
|
||||||
with open(filename, 'r', encoding='utf-8') as f:
|
with open(filename, 'r', encoding='utf-8') as f:
|
||||||
|
@ -164,11 +164,13 @@ from qutebrowser.browser import pdfjs
|
|||||||
id='manjaro', parsed=version.Distribution.manjaro,
|
id='manjaro', parsed=version.Distribution.manjaro,
|
||||||
version=None, pretty='Manjaro Linux')),
|
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'
|
os_release_file = tmpdir / 'os-release'
|
||||||
if os_release is not None:
|
if os_release is not None:
|
||||||
os_release_file.write(textwrap.dedent(os_release))
|
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:
|
class GitStrSubprocessFake:
|
||||||
|
Loading…
Reference in New Issue
Block a user