tests: Allow to mark files as qtwebengine_todo

This commit is contained in:
Florian Bruhin 2016-08-18 23:28:37 +02:00
parent 322a4323cb
commit 4d1ae999c6
3 changed files with 22 additions and 10 deletions

View File

@ -1,6 +1,9 @@
<!DOCTYPE html> <!DOCTYPE html>
<!-- target: hello.txt --> <!--
target: hello.txt
qtwebengine_todo: Doesn't seem to work?
-->
<html> <html>
<head> <head>

View File

@ -1,6 +1,9 @@
<!DOCTYPE html> <!DOCTYPE html>
<!-- target: hello.txt --> <!--
target: hello.txt
qtwebengine_todo: Doesn't seem to work?
-->
<html> <html>
<head> <head>

View File

@ -36,7 +36,8 @@ def collect_tests():
return files return files
ParsedFile = collections.namedtuple('ParsedFile', ['target']) ParsedFile = collections.namedtuple('ParsedFile', ['target',
'qtwebengine_todo'])
class InvalidFile(Exception): class InvalidFile(Exception):
@ -64,7 +65,7 @@ def _parse_file(test_name):
raise InvalidFile(test_name, "expected yaml dict but got {}".format( raise InvalidFile(test_name, "expected yaml dict but got {}".format(
type(data).__name__)) type(data).__name__))
allowed_keys = {'target'} allowed_keys = {'target', 'qtwebengine_todo'}
if not set(data.keys()).issubset(allowed_keys): if not set(data.keys()).issubset(allowed_keys):
raise InvalidFile(test_name, "expected keys {} but found {}".format( raise InvalidFile(test_name, "expected keys {} but found {}".format(
', '.join(allowed_keys), ', '.join(allowed_keys),
@ -73,7 +74,9 @@ def _parse_file(test_name):
if not 'target' in data: if not 'target' in data:
raise InvalidFile(test_name, "'target' key not found") raise InvalidFile(test_name, "'target' key not found")
return ParsedFile(target=data['target']) qtwebengine_todo = data.get('qtwebengine_todo', None)
return ParsedFile(target=data['target'], qtwebengine_todo=qtwebengine_todo)
@pytest.mark.parametrize('test_name', collect_tests()) @pytest.mark.parametrize('test_name', collect_tests())
@ -82,18 +85,21 @@ def _parse_file(test_name):
@pytest.mark.parametrize('find_implementation', ['javascript', 'python']) @pytest.mark.parametrize('find_implementation', ['javascript', 'python'])
def test_hints(test_name, zoom_text_only, zoom_level, find_implementation, def test_hints(test_name, zoom_text_only, zoom_level, find_implementation,
quteproc, request): quteproc, request):
if zoom_text_only and request.config.getoption('--qute-bdd-webengine'): webengine = bool(request.config.getoption('--qute-bdd-webengine'))
if zoom_text_only and webengine:
pytest.skip("QtWebEngine doesn't have zoom-text-only") pytest.skip("QtWebEngine doesn't have zoom-text-only")
if (find_implementation == 'python' and if find_implementation == 'python' and webengine:
request.config.getoption('--qute-bdd-webengine')):
pytest.skip("QtWebEngine doesn't have a python find implementation") pytest.skip("QtWebEngine doesn't have a python find implementation")
parsed = _parse_file(test_name) parsed = _parse_file(test_name)
if parsed.qtwebengine_todo is not None and webengine:
pytest.xfail("QtWebEngine TODO: {}".format(parsed.qtwebengine_todo))
url_path = 'data/hints/html/{}'.format(test_name) url_path = 'data/hints/html/{}'.format(test_name)
quteproc.open_path(url_path) quteproc.open_path(url_path)
# setup # setup
if not request.config.getoption('--qute-bdd-webengine'): if not webengine:
quteproc.set_setting('ui', 'zoom-text-only', str(zoom_text_only)) quteproc.set_setting('ui', 'zoom-text-only', str(zoom_text_only))
quteproc.set_setting('hints', 'find-implementation', quteproc.set_setting('hints', 'find-implementation',
find_implementation) find_implementation)
@ -105,7 +111,7 @@ def test_hints(test_name, zoom_text_only, zoom_level, find_implementation,
quteproc.wait_for_load_finished('data/' + parsed.target) quteproc.wait_for_load_finished('data/' + parsed.target)
# reset # reset
quteproc.send_cmd(':zoom 100') quteproc.send_cmd(':zoom 100')
if not request.config.getoption('--qute-bdd-webengine'): if not webengine:
quteproc.set_setting('ui', 'zoom-text-only', 'false') quteproc.set_setting('ui', 'zoom-text-only', 'false')
quteproc.set_setting('hints', 'find-implementation', 'javascript') quteproc.set_setting('hints', 'find-implementation', 'javascript')