File: test_js_api.py

package info (click to toggle)
python-pywebview 2.3%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 1,376 kB
  • sloc: python: 3,816; cs: 116; makefile: 3
file content (30 lines) | stat: -rwxr-xr-x 585 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import webview
from .util import run_test, assert_js


def test_js_bridge():
    run_test(webview, main_func, js_bridge)


class Api:
    def get_int(self, params):
        return 5

    def get_float(self, params):
        return 3.141

    def get_string(self, params):
        return 'test'


def main_func():
    api = Api()
    webview.create_window('JSBridge test', js_api=api)


def js_bridge():
    webview.load_html('<html><body>TEST</body></html>')
    assert_js(webview, 'get_int', 5)
    assert_js(webview, 'get_float', 3.141)
    assert_js(webview, 'get_string', 'test')