tests: Improve some ugly test IDs.

This commit is contained in:
Florian Bruhin 2015-12-16 22:21:29 +01:00
parent bba6589e19
commit e6284ed5d4
6 changed files with 15 additions and 10 deletions

View File

@ -105,7 +105,8 @@ def test_qt_log_ignore(qtbot, quteproc):
'00:00:00 DEBUG foo foo:foo:0 [2s ago] test',
{'prefix': '2s ago', 'message': 'test'}
),
])
], ids=['normal', 'vdebug', 'unknown module', 'expected message',
'weird Qt location', 'QXcbXSettings', '2s ago marker'])
def test_log_line_parse(data, attrs):
line = quteprocess.LogLine(data)
for name, expected in attrs.items():

View File

@ -263,7 +263,8 @@ def test_empty_content_type(checker):
}""", ['/bg-img.png']),
(True, 'background: url(folder/file.png) no-repeat', ['folder/file.png']),
(True, 'content: url()', []),
])
], ids=['import with apostrophe', 'import with quote', 'import with tab',
'import with url()', 'background with body', 'background', 'content'])
def test_css_url_scanner(monkeypatch, has_cssutils, inline, style,
expected_urls):
if not has_cssutils:

View File

@ -1145,7 +1145,9 @@ class TestRegex:
def test_validate_valid(self, klass, val):
klass(none_ok=True).validate(val)
@pytest.mark.parametrize('val', [r'(foo|bar))?baz[fis]h', '', '(' * 500])
@pytest.mark.parametrize('val', [r'(foo|bar))?baz[fis]h', '', '(' * 500],
ids=['unmatched parens', 'empty',
'too many parens'])
def test_validate_invalid(self, klass, val):
with pytest.raises(configexc.ValidationError):
klass().validate(val)
@ -1222,7 +1224,7 @@ class TestRegexList:
r'',
r'(foo|bar),((),1337{42}',
r'(' * 500,
])
], ids=['empty value', 'empty', 'unmatched parens', 'too many parens'])
def test_validate_invalid(self, klass, val):
with pytest.raises(configexc.ValidationError):
klass().validate(val)
@ -1329,7 +1331,7 @@ class TestFileAndUserStyleSheet:
(configtypes.File(), 'foobar', True),
(configtypes.UserStyleSheet(), 'foobar', False),
(configtypes.UserStyleSheet(), '\ud800', True),
])
], ids=['file-foobar', 'userstylesheet-foobar', 'userstylesheet-unicode'])
def test_validate_rel_inexistent(self, os_mock, monkeypatch, configtype,
value, raises):
"""Test with a relative path and standarddir.config returning None."""

View File

@ -94,7 +94,7 @@ class TestParseFatalStacktrace:
"QT_IM_MODULE = fcitx"
),
({'LANGUAGE': 'foo', 'LANG': 'en_US.UTF-8'}, "LANG = en_US.UTF-8"),
])
], ids=repr)
def test_get_environment_vars(monkeypatch, env, expected):
"""Test for crashdialog._get_environment_vars."""
for key in os.environ.copy():

View File

@ -163,20 +163,21 @@ class TestSimpleSplit:
'foo\nbar': ['foo', '\nbar'],
}
@pytest.mark.parametrize('test', TESTS)
@pytest.mark.parametrize('test', TESTS, ids=repr)
def test_str_split(self, test):
"""Test if the behavior matches str.split."""
assert split.simple_split(test) == test.rstrip().split()
@pytest.mark.parametrize('s, maxsplit',
[("foo bar baz", 1), (" foo bar baz ", 0)])
[("foo bar baz", 1), (" foo bar baz ", 0)],
ids=repr)
def test_str_split_maxsplit(self, s, maxsplit):
"""Test if the behavior matches str.split with given maxsplit."""
actual = split.simple_split(s, maxsplit=maxsplit)
expected = s.rstrip().split(maxsplit=maxsplit)
assert actual == expected
@pytest.mark.parametrize('test, expected', TESTS.items())
@pytest.mark.parametrize('test, expected', TESTS.items(), ids=repr)
def test_split_keep(self, test, expected):
"""Test splitting with keep=True."""
assert split.simple_split(test, keep=True) == expected

View File

@ -69,7 +69,7 @@ class TestCompactText:
(5, 'foobar', 'foob' + ELLIPSIS),
(5, 'foo\nbar', 'foob' + ELLIPSIS),
(7, 'foo\nbar', 'foobar'),
], ids=lambda val: str(val)[:20])
], ids=lambda val: repr(val)[:20])
def test_eliding(self, elidelength, text, expected):
"""Test eliding."""
assert utils.compact_text(text, elidelength) == expected