From 7d9d4937aaa910087889a74862d3761e06995580 Mon Sep 17 00:00:00 2001 From: Felix Van der Jeugt Date: Wed, 13 Apr 2016 11:25:54 +0200 Subject: [PATCH] initial testing - local tox does not work yet --- tests/integration/data/hinting.txt | 1 + tests/integration/data/hints/issue1393.html | 38 +++++++++++++++++++++ tests/integration/data/l33t.txt | 1 + tests/integration/data/smart.txt | 1 + tests/integration/data/words.txt | 1 + tests/integration/test_hints_html.py | 34 ++++++++++++++++++ 6 files changed, 76 insertions(+) create mode 100644 tests/integration/data/hinting.txt create mode 100644 tests/integration/data/hints/issue1393.html create mode 100644 tests/integration/data/l33t.txt create mode 100644 tests/integration/data/smart.txt create mode 100644 tests/integration/data/words.txt diff --git a/tests/integration/data/hinting.txt b/tests/integration/data/hinting.txt new file mode 100644 index 000000000..13db8e00b --- /dev/null +++ b/tests/integration/data/hinting.txt @@ -0,0 +1 @@ +hinting diff --git a/tests/integration/data/hints/issue1393.html b/tests/integration/data/hints/issue1393.html new file mode 100644 index 000000000..c1269d517 --- /dev/null +++ b/tests/integration/data/hints/issue1393.html @@ -0,0 +1,38 @@ + + + + + Let's Hint some words + + +

Word hints

+

This page contains links to be hinted with words. The two + kinds of word hints will be described below.

+ +

Smart hints

+

In qutebrowser, urls can not only be hinted with letters and + numbers, but also with words. When there is + a sensible url text available, qutebrowser will even use that + text to create a smart hint.

+ +

Filled hints

+

When no smart hints are available, because the hint text is + too short or l33t to + use, words from a dictionary will be used.

+ +

The current dictionary contains only the words: one, two, + three, four and five. As there are for none-smart hints in this + page, all five words should be used.

+ +

Hint conflicts

+

Of course, hints have to be unique. For instance, all hints + below should get a different hint, whether they're smart or + not:

+ + + diff --git a/tests/integration/data/l33t.txt b/tests/integration/data/l33t.txt new file mode 100644 index 000000000..1e2266cec --- /dev/null +++ b/tests/integration/data/l33t.txt @@ -0,0 +1 @@ +l33t diff --git a/tests/integration/data/smart.txt b/tests/integration/data/smart.txt new file mode 100644 index 000000000..c2d01532a --- /dev/null +++ b/tests/integration/data/smart.txt @@ -0,0 +1 @@ +smart diff --git a/tests/integration/data/words.txt b/tests/integration/data/words.txt new file mode 100644 index 000000000..71af1a951 --- /dev/null +++ b/tests/integration/data/words.txt @@ -0,0 +1 @@ +words diff --git a/tests/integration/test_hints_html.py b/tests/integration/test_hints_html.py index cc668193d..23f04fdc9 100644 --- a/tests/integration/test_hints_html.py +++ b/tests/integration/test_hints_html.py @@ -1,3 +1,4 @@ + # vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: # Copyright 2016 Florian Bruhin (The Compiler) @@ -21,10 +22,12 @@ import os import os.path +import re import yaml import pytest import bs4 +import textwrap def collect_tests(): @@ -54,3 +57,34 @@ def test_hints(test_name, quteproc): quteproc.wait_for(message='hints: a', category='hints') quteproc.send_cmd(':follow-hint a') quteproc.wait_for_load_finished('data/' + parsed['target']) + + +def test_word_hints_issue1393(quteproc, tmpdir): + dict_file = tmpdir / 'dict' + dict_file.write(textwrap.dedent(""" + alpha + beta + gamma + delta + epsilon + """)) + targets = [ + ('words', 'words.txt'), + ('smart', 'smart.txt'), + ('hinting', 'hinting.txt'), + ('alpha', 'l33t.txt'), + ('beta', 'l33t.txt'), + ('gamma', 'l33t.txt'), + ('delta', 'l33t.txt'), + ('epsilon', 'l33t.txt'), + ] + + quteproc.set_setting('hints', 'mode', 'words') + quteproc.set_setting('hints', 'dictionary', str(dict_file)) + + for hint, target in targets: + quteproc.open_path('data/hints/issue1393.html') + quteproc.send_cmd(':hint') + quteproc.wait_for(message=re.compile('hints: .*'), category='hints') + quteproc.send_cmd(':follow-hint {}'.format(hint)) + quteproc.wait_for_load_finished('data/{}'.format(target))