-
-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #375 from robertcv/fixes/viewer_highlight
[FIX] OWCorpusViewer: fix search highlighting
- Loading branch information
Showing
2 changed files
with
41 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import unittest | ||
from AnyQt.QtTest import QSignalSpy | ||
from Orange.widgets.tests.base import WidgetTest | ||
|
||
from orangecontrib.text.corpus import Corpus | ||
from orangecontrib.text.widgets.owcorpusviewer import OWCorpusViewer | ||
|
||
|
||
class TestCorpusViewerWidget(WidgetTest): | ||
def setUp(self): | ||
self.widget = self.create_widget(OWCorpusViewer) | ||
self.corpus = Corpus.from_file('deerwester') | ||
|
||
def test_data(self): | ||
self.send_signal(self.widget.Inputs.corpus, self.corpus) | ||
self.assertEqual(self.widget.n_documents, 9) | ||
out_corpus = self.get_output(self.widget.Outputs.matching_docs) | ||
self.assertEqual(out_corpus, self.corpus) | ||
|
||
def test_search(self): | ||
self.send_signal(self.widget.Inputs.corpus, self.corpus) | ||
self.widget.regexp_filter = "graph" | ||
self.process_events() | ||
out_corpus = self.get_output(self.widget.Outputs.matching_docs) | ||
self.assertEqual(len(out_corpus), 4) | ||
|
||
def test_highlighting(self): | ||
self.send_signal(self.widget.Inputs.corpus, self.corpus) | ||
self.widget.regexp_filter = "graph" | ||
self.process_events() | ||
self.widget.doc_webview.html() | ||
spy = QSignalSpy(self.widget.doc_webview.loadFinished) | ||
spy.wait() | ||
html = self.widget.doc_webview.html() | ||
self.assertIn('<mark data-markjs="true">', html) | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |