Skip to content

Commit 1a9d56a

Browse files
committed
test
1 parent ce1e17a commit 1a9d56a

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

mesop/component_helpers/helper.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ def compute_fn_id(fn: Callable[..., Any]) -> str:
387387
partial_args = (
388388
f"{args_str}{', ' if args_str and kwargs_str else ''}{kwargs_str}"
389389
)
390-
source_code = f"partial({inspect.getsource(fn.func)}, {partial_args})"
390+
source_code = f"partial(<<{inspect.getsource(fn.func)}>>, {partial_args})"
391391
print("source_code", source_code)
392392
fn_name = fn.func.__name__
393393
fn_module = fn.func.__module__

mesop/examples/functools_partial.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class State:
1111
@me.page(path="/functools_partial")
1212
def main():
1313
state = me.state(State)
14-
me.text(text=f"{state.count}")
14+
me.text(text=f"value={state.count}")
1515
me.button("increment 2*4", on_click=partial(increment_click, 2, amount=4))
1616
me.button("increment 2*10", on_click=partial(increment_click, 2, amount=10))
1717

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import {test, expect} from '@playwright/test';
2+
3+
test('functools partial', async ({page}) => {
4+
await page.goto('/functools_partial');
5+
6+
await page.getByRole('button', {name: 'increment 2*4'}).click();
7+
await expect(page.getByText('8')).toBeVisible();
8+
9+
await page.getByRole('button', {name: 'increment 2*10'}).click();
10+
await expect(page.getByText('28')).toBeVisible();
11+
});

0 commit comments

Comments
 (0)