Fix JSTester.run_file() for new pkg_resources
Read the file via open() instead of utils.read_file.
This commit is contained in:
parent
0e11b85474
commit
8642b6e8ce
@ -27,6 +27,7 @@ import jinja2
|
|||||||
|
|
||||||
from PyQt5.QtCore import QUrl
|
from PyQt5.QtCore import QUrl
|
||||||
|
|
||||||
|
import qutebrowser
|
||||||
from qutebrowser.utils import utils
|
from qutebrowser.utils import utils
|
||||||
|
|
||||||
|
|
||||||
@ -90,15 +91,16 @@ class JSTester:
|
|||||||
if not force:
|
if not force:
|
||||||
assert blocker.args == [True]
|
assert blocker.args == [True]
|
||||||
|
|
||||||
def run_file(self, filename: str, expected=None) -> None:
|
def run_file(self, path: str, expected=None) -> None:
|
||||||
"""Run a javascript file.
|
"""Run a javascript file.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
filename: The javascript filename, relative to
|
path: The path to the JS file, relative to the qutebrowser package.
|
||||||
qutebrowser/javascript.
|
|
||||||
expected: The value expected return from the javascript execution
|
expected: The value expected return from the javascript execution
|
||||||
"""
|
"""
|
||||||
source = utils.read_file(os.path.join('javascript', filename))
|
base_path = os.path.dirname(os.path.abspath(qutebrowser.__file__))
|
||||||
|
with open(os.path.join(base_path, path), 'r', encoding='utf-8') as f:
|
||||||
|
source = f.read()
|
||||||
self.run(source, expected)
|
self.run(source, expected)
|
||||||
|
|
||||||
def run(self, source: str, expected, world=None) -> None:
|
def run(self, source: str, expected, world=None) -> None:
|
||||||
|
@ -50,7 +50,7 @@ class CaretTester:
|
|||||||
|
|
||||||
def check(self):
|
def check(self):
|
||||||
"""Check whether the caret is before the MARKER text."""
|
"""Check whether the caret is before the MARKER text."""
|
||||||
self.js.run_file('position_caret.js')
|
self.js.run_file('javascript/position_caret.js')
|
||||||
self.js.tab.caret.toggle_selection()
|
self.js.tab.caret.toggle_selection()
|
||||||
self.js.tab.caret.move_to_next_word()
|
self.js.tab.caret.move_to_next_word()
|
||||||
|
|
||||||
|
@ -131,6 +131,6 @@ def test_set_error(stylesheet_tester, config_stub):
|
|||||||
def test_appendchild(stylesheet_tester):
|
def test_appendchild(stylesheet_tester):
|
||||||
stylesheet_tester.js.load('stylesheet/simple.html')
|
stylesheet_tester.js.load('stylesheet/simple.html')
|
||||||
stylesheet_tester.init_stylesheet()
|
stylesheet_tester.init_stylesheet()
|
||||||
js_test_file_path = ('../../tests/unit/javascript/stylesheet/'
|
js_test_file_path = ('../tests/unit/javascript/stylesheet/'
|
||||||
'test_appendchild.js')
|
'test_appendchild.js')
|
||||||
stylesheet_tester.js.run_file(js_test_file_path, {})
|
stylesheet_tester.js.run_file(js_test_file_path, {})
|
||||||
|
Loading…
Reference in New Issue
Block a user