11import datetime
22
33import pytest
4+ import pytest_asyncio
45
56import flet as ft
67import flet .testing as ftt
78
89
9- @pytest .mark .asyncio (loop_scope = "module" )
10+ # Create a new flet_app instance for each test method
11+ @pytest_asyncio .fixture (scope = "function" , autouse = True )
12+ def flet_app (flet_app_function ):
13+ return flet_app_function
14+
15+
16+ @pytest .mark .asyncio (loop_scope = "function" )
1017async def test_basic (flet_app : ftt .FletTestApp , request ):
1118 dp = ft .DateRangePicker (
1219 start_value = datetime .datetime (year = 2000 , month = 10 , day = 1 ),
1320 end_value = datetime .datetime (year = 2000 , month = 10 , day = 15 ),
21+ first_date = datetime .datetime (year = 2000 , month = 10 , day = 1 ),
22+ last_date = datetime .datetime (year = 2000 , month = 11 , day = 15 ),
23+ current_date = datetime .datetime (year = 2000 , month = 10 , day = 16 ),
1424 )
1525 flet_app .page .enable_screenshots = True
1626 flet_app .page .window .width = 400
@@ -25,3 +35,44 @@ async def test_basic(flet_app: ftt.FletTestApp, request):
2535 pixel_ratio = flet_app .screenshots_pixel_ratio
2636 ),
2737 )
38+
39+
40+ @pytest .mark .asyncio (loop_scope = "function" )
41+ async def test_properties1 (flet_app : ftt .FletTestApp , request ):
42+ dp = ft .DateRangePicker (
43+ start_value = datetime .datetime (year = 2000 , month = 10 , day = 7 ),
44+ end_value = datetime .datetime (year = 2000 , month = 10 , day = 15 ),
45+ first_date = datetime .datetime (year = 2000 , month = 10 , day = 1 ),
46+ last_date = datetime .datetime (year = 2000 , month = 11 , day = 15 ),
47+ current_date = datetime .datetime (year = 2000 , month = 10 , day = 16 ),
48+ switch_to_calendar_icon = ft .Icons .BABY_CHANGING_STATION ,
49+ switch_to_input_icon = ft .Icons .ACCESS_ALARM ,
50+ save_text = "Custom save text" ,
51+ error_invalid_range_text = "Invalid range custom text" ,
52+ help_text = "Custom help text" ,
53+ cancel_text = "Custom cancel text" ,
54+ confirm_text = "Custom confirm text" ,
55+ error_format_text = "Custom error format text" ,
56+ error_invalid_text = "Custom error invalid text" ,
57+ field_end_hint_text = "Custom end hint text" ,
58+ field_start_hint_text = "Custom start hint text" ,
59+ field_end_label_text = "Custom end label text" ,
60+ field_start_label_text = "Custom start label text" ,
61+ modal = False ,
62+ barrier_color = ft .Colors .RED ,
63+ keyboard_type = ft .KeyboardType .EMAIL ,
64+ date_picker_entry_mode = ft .DatePickerEntryMode .CALENDAR ,
65+ )
66+ flet_app .page .enable_screenshots = True
67+ flet_app .page .window .width = 400
68+ flet_app .page .window .height = 600
69+ flet_app .page .show_dialog (dp )
70+ flet_app .page .update ()
71+ await flet_app .tester .pump_and_settle ()
72+
73+ flet_app .assert_screenshot (
74+ "properties1" ,
75+ await flet_app .page .take_screenshot (
76+ pixel_ratio = flet_app .screenshots_pixel_ratio
77+ ),
78+ )
0 commit comments