tests: Make test IDs predictable.
This means we could use xdist in the future.
This commit is contained in:
parent
8e5014fc0f
commit
4d9ea06768
@ -599,7 +599,7 @@ class TestJavascriptEscape:
|
||||
# http://qutebrowser.org:8010/builders/debian-jessie/builds/765/steps/unittests/
|
||||
# Should that be ignored?
|
||||
|
||||
@pytest.mark.parametrize('before, after', TESTS.items(), ids=repr)
|
||||
@pytest.mark.parametrize('before, after', sorted(TESTS.items()), ids=repr)
|
||||
def test_fake_escape(self, before, after):
|
||||
"""Test javascript escaping with some expected outcomes."""
|
||||
assert webelem.javascript_escape(before) == after
|
||||
@ -645,7 +645,7 @@ class TestJavascriptEscape:
|
||||
result = webframe.evaluateJavaScript('"{}";'.format(escaped))
|
||||
assert result == text
|
||||
|
||||
@pytest.mark.parametrize('text', TESTS, ids=repr)
|
||||
@pytest.mark.parametrize('text', sorted(TESTS), ids=repr)
|
||||
def test_real_escape(self, webframe, qtbot, text):
|
||||
"""Test javascript escaping with a real QWebPage."""
|
||||
self._test_escape(text, qtbot, webframe)
|
||||
|
@ -189,7 +189,7 @@ class TestConfigParser:
|
||||
assert new_sect in configdata.DATA
|
||||
|
||||
@pytest.mark.parametrize('old_tuple, new_option',
|
||||
config.ConfigManager.RENAMED_OPTIONS.items())
|
||||
sorted(config.ConfigManager.RENAMED_OPTIONS.items()))
|
||||
def test_renamed_options(self, old_tuple, new_option):
|
||||
"""Make sure renamed options exist under the new name."""
|
||||
section, old_option = old_tuple
|
||||
|
@ -254,7 +254,7 @@ class TestMappingType:
|
||||
def klass(self):
|
||||
return MappingSubclass
|
||||
|
||||
@pytest.mark.parametrize('val', TESTS.keys())
|
||||
@pytest.mark.parametrize('val', sorted(TESTS.keys()))
|
||||
def test_validate_valid(self, klass, val):
|
||||
klass(none_ok=True).validate(val)
|
||||
|
||||
@ -263,7 +263,7 @@ class TestMappingType:
|
||||
with pytest.raises(configexc.ValidationError):
|
||||
klass().validate(val)
|
||||
|
||||
@pytest.mark.parametrize('val, expected', TESTS.items())
|
||||
@pytest.mark.parametrize('val, expected', sorted(TESTS.items()))
|
||||
def test_transform(self, klass, val, expected):
|
||||
assert klass().transform(val) == expected
|
||||
|
||||
@ -488,11 +488,11 @@ class TestBool:
|
||||
def klass(self):
|
||||
return configtypes.Bool
|
||||
|
||||
@pytest.mark.parametrize('val, expected', TESTS.items())
|
||||
@pytest.mark.parametrize('val, expected', sorted(TESTS.items()))
|
||||
def test_transform(self, klass, val, expected):
|
||||
assert klass().transform(val) == expected
|
||||
|
||||
@pytest.mark.parametrize('val', TESTS)
|
||||
@pytest.mark.parametrize('val', sorted(TESTS))
|
||||
def test_validate_valid(self, klass, val):
|
||||
klass(none_ok=True).validate(val)
|
||||
|
||||
@ -518,11 +518,11 @@ class TestBoolAsk:
|
||||
def klass(self):
|
||||
return configtypes.BoolAsk
|
||||
|
||||
@pytest.mark.parametrize('val, expected', TESTS.items())
|
||||
@pytest.mark.parametrize('val, expected', sorted(TESTS.items()))
|
||||
def test_transform(self, klass, val, expected):
|
||||
assert klass().transform(val) == expected
|
||||
|
||||
@pytest.mark.parametrize('val', TESTS)
|
||||
@pytest.mark.parametrize('val', sorted(TESTS))
|
||||
def test_validate_valid(self, klass, val):
|
||||
klass(none_ok=True).validate(val)
|
||||
|
||||
@ -871,7 +871,7 @@ class TestColorSystem:
|
||||
def klass(self):
|
||||
return configtypes.ColorSystem
|
||||
|
||||
@pytest.mark.parametrize('val', TESTS)
|
||||
@pytest.mark.parametrize('val', sorted(TESTS))
|
||||
def test_validate_valid(self, klass, val):
|
||||
klass(none_ok=True).validate(val)
|
||||
|
||||
@ -880,7 +880,7 @@ class TestColorSystem:
|
||||
with pytest.raises(configexc.ValidationError):
|
||||
klass().validate(val)
|
||||
|
||||
@pytest.mark.parametrize('val, expected', TESTS.items())
|
||||
@pytest.mark.parametrize('val, expected', sorted(TESTS.items()))
|
||||
def test_transform(self, klass, val, expected):
|
||||
assert klass().transform(val) == expected
|
||||
|
||||
@ -1048,7 +1048,7 @@ class TestFont:
|
||||
def qtfont_class(self):
|
||||
return configtypes.QtFont
|
||||
|
||||
@pytest.mark.parametrize('val', list(TESTS) + [''])
|
||||
@pytest.mark.parametrize('val', sorted(list(TESTS)) + [''])
|
||||
def test_validate_valid(self, klass, val):
|
||||
klass(none_ok=True).validate(val)
|
||||
|
||||
@ -1077,11 +1077,11 @@ class TestFont:
|
||||
with pytest.raises(configexc.ValidationError):
|
||||
klass().validate('')
|
||||
|
||||
@pytest.mark.parametrize('string', TESTS)
|
||||
@pytest.mark.parametrize('string', sorted(TESTS))
|
||||
def test_transform_font(self, font_class, string):
|
||||
assert font_class().transform(string) == string
|
||||
|
||||
@pytest.mark.parametrize('string, desc', TESTS.items())
|
||||
@pytest.mark.parametrize('string, desc', sorted(TESTS.items()))
|
||||
def test_transform_qtfont(self, qtfont_class, string, desc):
|
||||
assert Font(qtfont_class().transform(string)) == Font.fromdesc(desc)
|
||||
|
||||
@ -1829,7 +1829,7 @@ class TestAutoSearch:
|
||||
def klass(self):
|
||||
return configtypes.AutoSearch
|
||||
|
||||
@pytest.mark.parametrize('val', TESTS)
|
||||
@pytest.mark.parametrize('val', sorted(TESTS))
|
||||
def test_validate_valid(self, klass, val):
|
||||
klass(none_ok=True).validate(val)
|
||||
|
||||
@ -1838,7 +1838,7 @@ class TestAutoSearch:
|
||||
with pytest.raises(configexc.ValidationError):
|
||||
klass().validate(val)
|
||||
|
||||
@pytest.mark.parametrize('val, expected', TESTS.items())
|
||||
@pytest.mark.parametrize('val, expected', sorted(TESTS.items()))
|
||||
def test_transform(self, klass, val, expected):
|
||||
assert klass().transform(val) == expected
|
||||
|
||||
@ -1859,7 +1859,7 @@ class TestIgnoreCase:
|
||||
def klass(self):
|
||||
return configtypes.IgnoreCase
|
||||
|
||||
@pytest.mark.parametrize('val', TESTS)
|
||||
@pytest.mark.parametrize('val', sorted(TESTS))
|
||||
def test_validate_valid(self, klass, val):
|
||||
klass(none_ok=True).validate(val)
|
||||
|
||||
@ -1868,7 +1868,7 @@ class TestIgnoreCase:
|
||||
with pytest.raises(configexc.ValidationError):
|
||||
klass().validate(val)
|
||||
|
||||
@pytest.mark.parametrize('val, expected', TESTS.items())
|
||||
@pytest.mark.parametrize('val, expected', sorted(TESTS.items()))
|
||||
def test_transform(self, klass, val, expected):
|
||||
assert klass().transform(val) == expected
|
||||
|
||||
@ -1910,7 +1910,7 @@ class TestUrlList:
|
||||
def klass(self):
|
||||
return configtypes.UrlList
|
||||
|
||||
@pytest.mark.parametrize('val', TESTS)
|
||||
@pytest.mark.parametrize('val', sorted(TESTS))
|
||||
def test_validate_valid(self, klass, val):
|
||||
klass(none_ok=True).validate(val)
|
||||
|
||||
@ -1928,7 +1928,7 @@ class TestUrlList:
|
||||
with pytest.raises(configexc.ValidationError):
|
||||
klass().validate('foo,,bar')
|
||||
|
||||
@pytest.mark.parametrize('val, expected', TESTS.items())
|
||||
@pytest.mark.parametrize('val, expected', sorted(TESTS.items()))
|
||||
def test_transform_single(self, klass, val, expected):
|
||||
assert klass().transform(val) == expected
|
||||
|
||||
@ -1968,7 +1968,7 @@ class TestConfirmQuit:
|
||||
def klass(self):
|
||||
return configtypes.ConfirmQuit
|
||||
|
||||
@pytest.mark.parametrize('val', TESTS.keys())
|
||||
@pytest.mark.parametrize('val', sorted(TESTS.keys()))
|
||||
def test_validate_valid(self, klass, val):
|
||||
klass(none_ok=True).validate(val)
|
||||
|
||||
@ -1985,7 +1985,7 @@ class TestConfirmQuit:
|
||||
with pytest.raises(configexc.ValidationError):
|
||||
klass().validate(val)
|
||||
|
||||
@pytest.mark.parametrize('val, expected', TESTS.items())
|
||||
@pytest.mark.parametrize('val, expected', sorted(TESTS.items()))
|
||||
def test_transform(self, klass, val, expected):
|
||||
assert klass().transform(val) == expected
|
||||
|
||||
|
@ -94,7 +94,7 @@ class TestParseFatalStacktrace:
|
||||
"QT_IM_MODULE = fcitx"
|
||||
),
|
||||
({'LANGUAGE': 'foo', 'LANG': 'en_US.UTF-8'}, "LANG = en_US.UTF-8"),
|
||||
], ids=repr)
|
||||
], ids=lambda e: e[1])
|
||||
def test_get_environment_vars(monkeypatch, env, expected):
|
||||
"""Test for crashdialog._get_environment_vars."""
|
||||
for key in os.environ.copy():
|
||||
|
@ -126,7 +126,8 @@ class TestSplit:
|
||||
|
||||
"""Test split."""
|
||||
|
||||
@pytest.fixture(params=_parse_split_test_data_str(), ids=lambda e: e.input)
|
||||
@pytest.fixture(params=list(_parse_split_test_data_str()),
|
||||
ids=lambda e: e.input)
|
||||
def split_test_case(self, request):
|
||||
"""Fixture to automatically parametrize all depending tests.
|
||||
|
||||
@ -163,7 +164,7 @@ class TestSimpleSplit:
|
||||
'foo\nbar': ['foo', '\nbar'],
|
||||
}
|
||||
|
||||
@pytest.mark.parametrize('test', TESTS, ids=repr)
|
||||
@pytest.mark.parametrize('test', sorted(TESTS), ids=repr)
|
||||
def test_str_split(self, test):
|
||||
"""Test if the behavior matches str.split."""
|
||||
assert split.simple_split(test) == test.rstrip().split()
|
||||
@ -177,7 +178,7 @@ class TestSimpleSplit:
|
||||
expected = s.rstrip().split(maxsplit=maxsplit)
|
||||
assert actual == expected
|
||||
|
||||
@pytest.mark.parametrize('test, expected', TESTS.items(), ids=repr)
|
||||
@pytest.mark.parametrize('test, expected', sorted(TESTS.items()), ids=repr)
|
||||
def test_split_keep(self, test, expected):
|
||||
"""Test splitting with keep=True."""
|
||||
assert split.simple_split(test, keep=True) == expected
|
||||
|
@ -49,12 +49,20 @@ BAD_VALUES = {
|
||||
}
|
||||
|
||||
|
||||
def good_values():
|
||||
return list(iter_good_values())
|
||||
|
||||
|
||||
def bad_values():
|
||||
return list(iter_bad_values())
|
||||
|
||||
|
||||
def iter_good_values():
|
||||
"""Yield "good" (C data type, value) tuples.
|
||||
|
||||
Those should pass overflow checking.
|
||||
"""
|
||||
for ctype, values in GOOD_VALUES.items():
|
||||
for ctype, values in sorted(GOOD_VALUES.items()):
|
||||
for value in values:
|
||||
yield ctype, value
|
||||
|
||||
@ -65,6 +73,6 @@ def iter_bad_values():
|
||||
These should not pass overflow checking. The third value is the value they
|
||||
should be replaced with if overflow checking should not be fatal.
|
||||
"""
|
||||
for ctype, values in BAD_VALUES.items():
|
||||
for ctype, values in sorted(BAD_VALUES.items()):
|
||||
for value, repl in values:
|
||||
yield ctype, value, repl
|
||||
|
@ -69,21 +69,21 @@ class TestCheckOverflow:
|
||||
"""Test check_overflow."""
|
||||
|
||||
@pytest.mark.parametrize('ctype, val',
|
||||
overflow_test_cases.iter_good_values())
|
||||
overflow_test_cases.good_values())
|
||||
def test_good_values(self, ctype, val):
|
||||
"""Test values which are inside bounds."""
|
||||
qtutils.check_overflow(val, ctype)
|
||||
|
||||
@pytest.mark.parametrize('ctype, val',
|
||||
[(ctype, val) for (ctype, val, _) in
|
||||
overflow_test_cases.iter_bad_values()])
|
||||
overflow_test_cases.bad_values()])
|
||||
def test_bad_values_fatal(self, ctype, val):
|
||||
"""Test values which are outside bounds with fatal=True."""
|
||||
with pytest.raises(OverflowError):
|
||||
qtutils.check_overflow(val, ctype)
|
||||
|
||||
@pytest.mark.parametrize('ctype, val, repl',
|
||||
overflow_test_cases.iter_bad_values())
|
||||
overflow_test_cases.bad_values())
|
||||
def test_bad_values_nonfatal(self, ctype, val, repl):
|
||||
"""Test values which are outside bounds with fatal=False."""
|
||||
newval = qtutils.check_overflow(val, ctype, fatal=False)
|
||||
|
@ -805,7 +805,8 @@ QUALNAME_OBJ = QualnameObj()
|
||||
(qutebrowser, 'qutebrowser'), # module
|
||||
(qutebrowser.utils, 'qutebrowser.utils'), # submodule
|
||||
(utils, 'qutebrowser.utils.utils'), # submodule (from-import)
|
||||
])
|
||||
], ids=['instance', 'class', 'unbound-method', 'bound-method', 'function',
|
||||
'partial', 'module', 'submodule', 'from-import'])
|
||||
def test_qualname(obj, expected):
|
||||
assert utils.qualname(obj) == expected
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user