1+ import inspect
2+
3+ import dash_bootstrap_components as dbc
4+ import pytest
15from dash import Dash , html
2- from dash_bootstrap_components import Checklist , RadioItems , Select
6+ from dash_bootstrap_components . _components import __all__ as COMPONENT_NAMES
37from selenium .webdriver .common .by import By
48
59
610def test_dbpa001_checklist (dash_duo ):
711 """
8- Check that the options and value positional arguments are working for
9- Checklist.
12+ Check that the options and value positional arguments are working for dbc.Checklist.
1013 """
1114 app = Dash ()
1215
@@ -18,12 +21,12 @@ def test_dbpa001_checklist(dash_duo):
1821
1922 value = "OptionB"
2023
21- with_keywords = Checklist (
24+ with_keywords = dbc . Checklist (
2225 options = options ,
2326 value = value ,
2427 id = "with-keywords" ,
2528 )
26- without_keywords = Checklist (options , value , id = "without-keywords" )
29+ without_keywords = dbc . Checklist (options , value , id = "without-keywords" )
2730
2831 app .layout = html .Div ([with_keywords , without_keywords ])
2932
@@ -59,7 +62,7 @@ def test_dbpa001_checklist(dash_duo):
5962def test_dbpa002_radio_items (dash_duo ):
6063 """
6164 Check that the options and value positional arguments are working for
62- RadioItems.
65+ dbc. RadioItems.
6366 """
6467 app = Dash ()
6568
@@ -71,12 +74,12 @@ def test_dbpa002_radio_items(dash_duo):
7174
7275 value = "OptionB"
7376
74- with_keywords = RadioItems (
77+ with_keywords = dbc . RadioItems (
7578 options = options ,
7679 value = value ,
7780 id = "with-keywords" ,
7881 )
79- without_keywords = RadioItems (options , value , id = "without-keywords" )
82+ without_keywords = dbc . RadioItems (options , value , id = "without-keywords" )
8083
8184 app .layout = html .Div ([with_keywords , without_keywords ])
8285
@@ -111,8 +114,7 @@ def test_dbpa002_radio_items(dash_duo):
111114
112115def test_dbpa003_select (dash_duo ):
113116 """
114- Check that the options and value positional arguments are working for
115- Select.
117+ Check that the options and value positional arguments are working for dbc.Select.
116118 """
117119 app = Dash ()
118120
@@ -124,12 +126,12 @@ def test_dbpa003_select(dash_duo):
124126
125127 value = "OptionB"
126128
127- with_keywords = Select (
129+ with_keywords = dbc . Select (
128130 options = options ,
129131 value = value ,
130132 id = "with-keywords" ,
131133 )
132- without_keywords = Select (options , value , id = "without-keywords" )
134+ without_keywords = dbc . Select (options , value , id = "without-keywords" )
133135
134136 app .layout = html .Div ([with_keywords , without_keywords ])
135137
@@ -160,3 +162,21 @@ def test_dbpa003_select(dash_duo):
160162 by = By .TAG_NAME , value = "option"
161163 )
162164 ]
165+
166+
167+ @pytest .mark .parametrize ("component_name" , COMPONENT_NAMES )
168+ def test_dbpa004_keyword_only_args (component_name ):
169+ component = getattr (dbc , component_name )
170+ signature = inspect .signature (component )
171+ id_seen = False
172+ for name , param in signature .parameters .items ():
173+ if name == "id" :
174+ id_seen = True
175+ elif id_seen :
176+ # all parameters after the id should be keyword only or **kwargs
177+ assert param .kind in (
178+ inspect .Parameter .KEYWORD_ONLY ,
179+ inspect .Parameter .VAR_KEYWORD ,
180+ )
181+
182+ assert id_seen
0 commit comments