trying to fix tests

This commit is contained in:
Alexey Nabrodov 2015-10-01 16:26:56 +03:00
parent 54d4f4f48b
commit 044c0a0c4f

View File

@ -81,23 +81,37 @@ class TestParseFatalStacktrace:
assert (typ, func) == ('', '')
@pytest.mark.parametrize('env, expected', [
({'FOO': 'bar'}, ""),
({'FOO': 'bar', 'LC_ALL': 'baz'}, "LC_ALL = baz"),
({'LC_ALL': 'baz', 'PYTHONFOO': 'fish'}, "LC_ALL = baz\nPYTHONFOO = fish"),
(
{'DE': 'KDE', 'DESKTOP_SESSION': 'plasma'},
"DE = KDE\nDESKTOP_SESSION = plasma"
),
(
{'QT5_IM_MODULE': 'fcitx', 'QT_IM_MODULE': 'fcitx'},
"QT_IM_MODULE = fcitx"
),
({'LANGUAGE': 'foo', 'LANG': 'en_US.UTF-8'}, "LANG = en_US.UTF-8"),
])
def test_get_environment_vars(monkeypatch, env, expected):
"""Test for crashdialog._get_environment_vars."""
os.environ = {}
for k, v in env.items():
monkeypatch.setenv(k, v)
assert crashdialog._get_environment_vars() == expected
class TestCrashDialog:
"""Tests for crashdialog."""
@classmethod
def setup_class(cls):
"""Clear env."""
cls.env = os.environ.copy()
os.environ = {}
@classmethod
def teardown_class(cls):
"""Restore env."""
os.environ = cls.env.copy()
@pytest.mark.parametrize('env, expected', [
({'FOO': 'bar'}, ""),
({'FOO': 'bar', 'LC_ALL': 'baz'}, "LC_ALL = baz"),
({'LC_ALL': 'baz', 'PYTHONFOO': 'fish'}, "LC_ALL = baz\nPYTHONFOO = fish"),
(
{'DE': 'KDE', 'DESKTOP_SESSION': 'plasma'},
"DE = KDE\nDESKTOP_SESSION = plasma"
),
(
{'QT5_IM_MODULE': 'fcitx', 'QT_IM_MODULE': 'fcitx'},
"QT_IM_MODULE = fcitx"
),
({'LANGUAGE': 'foo', 'LANG': 'en_US.UTF-8'}, "LANG = en_US.UTF-8"),
])
def test_get_environment_vars(self, monkeypatch, env, expected):
"""Test for crashdialog._get_environment_vars."""
for k, v in env.items():
monkeypatch.setenv(k, v)
assert crashdialog._get_environment_vars() == expected