Empty osver for linux, adjust test to match this.
This commit is contained in:
parent
ddeabc6643
commit
2e62d24062
@ -162,7 +162,7 @@ def _os_info():
|
|||||||
lines = []
|
lines = []
|
||||||
releaseinfo = None
|
releaseinfo = None
|
||||||
if sys.platform == 'linux':
|
if sys.platform == 'linux':
|
||||||
osver = ', '.join([e for e in platform.linux_distribution() if e])
|
osver = ''
|
||||||
releaseinfo = _release_info()
|
releaseinfo = _release_info()
|
||||||
elif sys.platform == 'win32':
|
elif sys.platform == 'win32':
|
||||||
osver = ', '.join(platform.win32_ver())
|
osver = ', '.join(platform.win32_ver())
|
||||||
|
@ -451,25 +451,16 @@ class TestOsInfo:
|
|||||||
|
|
||||||
"""Tests for _os_info."""
|
"""Tests for _os_info."""
|
||||||
|
|
||||||
@pytest.mark.parametrize('dist, dist_str', [
|
def test_linux_fake(self, monkeypatch):
|
||||||
(('x', '', 'y'), 'x, y'),
|
|
||||||
(('a', 'b', 'c'), 'a, b, c'),
|
|
||||||
(('', '', ''), ''),
|
|
||||||
])
|
|
||||||
def test_linux_fake(self, monkeypatch, dist, dist_str):
|
|
||||||
"""Test with a fake Linux.
|
"""Test with a fake Linux.
|
||||||
|
|
||||||
Args:
|
No args because osver is set to '' if the OS is linux.
|
||||||
dist: The value to set platform.linux_distribution() to.
|
|
||||||
dist_str: The expected distribution string in version._os_info().
|
|
||||||
"""
|
"""
|
||||||
monkeypatch.setattr('qutebrowser.utils.version.sys.platform', 'linux')
|
monkeypatch.setattr('qutebrowser.utils.version.sys.platform', 'linux')
|
||||||
monkeypatch.setattr('qutebrowser.utils.version._release_info',
|
monkeypatch.setattr('qutebrowser.utils.version._release_info',
|
||||||
lambda: [('releaseinfo', 'Hello World')])
|
lambda: [('releaseinfo', 'Hello World')])
|
||||||
monkeypatch.setattr('qutebrowser.utils.version.platform.linux_distribution',
|
|
||||||
lambda: dist)
|
|
||||||
ret = version._os_info()
|
ret = version._os_info()
|
||||||
expected = ['OS Version: {}'.format(dist_str), '',
|
expected = ['OS Version: ', '',
|
||||||
'--- releaseinfo ---', 'Hello World']
|
'--- releaseinfo ---', 'Hello World']
|
||||||
assert ret == expected
|
assert ret == expected
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user