()
| 18 | |
| 19 | |
| 20 | def target(): |
| 21 | # test session data |
| 22 | g = data() |
| 23 | assert g.none is None |
| 24 | g.one = 1 |
| 25 | g.one += 1 |
| 26 | assert g.one == 2 |
| 27 | |
| 28 | local.name = "Wang" |
| 29 | local.age = 22 |
| 30 | assert len(local) == 3 |
| 31 | assert local['age'] is local.age |
| 32 | assert local.foo is None |
| 33 | local[10] = "10" |
| 34 | del local['name'] |
| 35 | del local.one |
| 36 | |
| 37 | for key in local: |
| 38 | print(key) |
| 39 | |
| 40 | assert 'bar' not in local |
| 41 | assert 'age' in local |
| 42 | assert local._dict == {'age': 22, 10: '10'} |
| 43 | print(local) |
| 44 | |
| 45 | # test eval_js promise |
| 46 | import random |
| 47 | val = random.randint(1, 9999999) |
| 48 | promise_res = yield eval_js('''new Promise((resolve,reject) => { |
| 49 | setTimeout(() => { |
| 50 | resolve(val); |
| 51 | }, 1); |
| 52 | });''', val=val) |
| 53 | print(promise_res, val) |
| 54 | assert promise_res == val |
| 55 | |
| 56 | # test pywebio.utils |
| 57 | async def corofunc(**kwargs): |
| 58 | pass |
| 59 | |
| 60 | def genfunc(**kwargs): |
| 61 | yield |
| 62 | |
| 63 | corofunc = partial(corofunc, a=1) |
| 64 | genfunc = partial(genfunc, a=1) |
| 65 | |
| 66 | assert isgeneratorfunction(genfunc) |
| 67 | assert iscoroutinefunction(corofunc) |
| 68 | assert get_function_name(corofunc) == 'corofunc' |
| 69 | |
| 70 | get_free_port() |
| 71 | |
| 72 | try: |
| 73 | yield put_buttons([{'label': 'must not be shown'}], onclick=[lambda: None]) |
| 74 | except Exception: |
| 75 | pass |
| 76 | |
| 77 | put_table([ |
no test coverage detected
searching dependent graphs…