Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
🧹 Fix pylint issues in test_time_datetime_inputs.py
- Remove unused pytest import
- Clean up trailing whitespace
- Code now rated 10.00/10 by pylint
  • Loading branch information
LeticiaBN committed Sep 27, 2025
commit f516e6eefc329446f55561be0008dc4e7937f25c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
input types that were previously unsupported in dcc.Input.
"""

import pytest
from dash import Dash, Input, Output, dcc, html


Expand All @@ -21,28 +20,28 @@ def test_time_input_functionality(dash_dcc):
),
html.Div(id='time-output')
])

@app.callback(
Output('time-output', 'children'),
Input('time-input', 'value')
)
def update_time_output(time_value):
return f"Time: {time_value}"

dash_dcc.start_server(app)

# Check that the input has the correct type
time_input = dash_dcc.find_element('#time-input')
assert time_input.get_attribute('type') == 'time'
assert time_input.get_attribute('value') == '14:30:15'

# Test updating the time value
time_input.clear()
time_input.send_keys('09:45:30')

# Wait for callback to update
dash_dcc.wait_for_text_to_equal('#time-output', 'Time: 09:45:30')

assert dash_dcc.get_logs() == []


Expand All @@ -58,28 +57,28 @@ def test_datetime_local_input_functionality(dash_dcc):
),
html.Div(id='datetime-output')
])

@app.callback(
Output('datetime-output', 'children'),
Input('datetime-input', 'value')
)
def update_datetime_output(datetime_value):
return f"DateTime: {datetime_value}"

dash_dcc.start_server(app)

# Check that the input has the correct type
datetime_input = dash_dcc.find_element('#datetime-input')
assert datetime_input.get_attribute('type') == 'datetime-local'
assert datetime_input.get_attribute('value') == '2023-12-25T18:30:00'

# Test updating the datetime value
datetime_input.clear()
datetime_input.send_keys('2024-01-01T12:00:00')

# Wait for callback to update
dash_dcc.wait_for_text_to_equal('#datetime-output', 'DateTime: 2024-01-01T12:00:00')

assert dash_dcc.get_logs() == []


Expand All @@ -95,28 +94,28 @@ def test_time_input_with_debounce(dash_dcc):
),
html.Div(id='time-debounce-output')
])

@app.callback(
Output('time-debounce-output', 'children'),
Input('time-debounce-input', 'value')
)
def update_debounce_output(time_value):
return f"Time with debounce: {time_value}"

dash_dcc.start_server(app)

time_input = dash_dcc.find_element('#time-debounce-input')
assert time_input.get_attribute('type') == 'time'

# With debounce=True, value should update only after losing focus or Enter key
time_input.clear()
time_input.send_keys('15:30:45')

# Trigger blur event to commit the debounced value
dash_dcc.find_element('body').click() # Click somewhere else to blur

dash_dcc.wait_for_text_to_equal('#time-debounce-output', 'Time with debounce: 15:30:45')

assert dash_dcc.get_logs() == []


Expand All @@ -133,20 +132,20 @@ def test_datetime_local_input_with_min_max(dash_dcc):
),
html.Div(id='datetime-minmax-output')
])

@app.callback(
Output('datetime-minmax-output', 'children'),
Input('datetime-minmax-input', 'value')
)
def update_minmax_output(datetime_value):
return f"DateTime with constraints: {datetime_value}"

dash_dcc.start_server(app)

datetime_input = dash_dcc.find_element('#datetime-minmax-input')
assert datetime_input.get_attribute('type') == 'datetime-local'
assert datetime_input.get_attribute('min') == '2023-01-01T00:00:00'
assert datetime_input.get_attribute('max') == '2023-12-31T23:59:59'
assert datetime_input.get_attribute('value') == '2023-06-15T12:00:00'

assert dash_dcc.get_logs() == []