MCPcopy
hub / github.com/marimo-team/marimo / test_datetime

Function test_datetime

tests/_plugins/ui/_impl/test_dates.py:31–61  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

29
30
31def test_datetime() -> None:
32 # Test default initialization
33 dt = ui.datetime()
34 now = datetime.datetime.now()
35 assert dt.value
36 assert dt.value.date() == now.date()
37 assert dt.value.hour == now.hour
38 assert dt.value.minute == now.minute
39
40 # Test initialization with a specific value
41 dt = ui.datetime(value="2024-01-01T12:30")
42 assert dt.value == datetime.datetime(2024, 1, 1, 12, 30)
43 # Test initialization with a specific value
44 dt = ui.datetime(value="2024-01-01T12")
45 assert dt.value == datetime.datetime(2024, 1, 1, 12)
46 dt = ui.datetime(value="2024-01-01")
47 assert dt.value == datetime.datetime(2024, 1, 1)
48
49 # Test updating the value
50 dt._update("2024-02-15T08:45")
51 assert dt.value == datetime.datetime(2024, 2, 15, 8, 45)
52
53 # Test with start and stop
54 dt = ui.datetime(
55 value="2024-01-15T10:00",
56 start="2024-01-01T00:00",
57 stop="2024-12-31T23:59",
58 )
59 assert dt.value == datetime.datetime(2024, 1, 15, 10, 0)
60 assert dt.start == datetime.datetime(2024, 1, 1, 0, 0)
61 assert dt.stop == datetime.datetime(2024, 12, 31, 23, 59)
62
63
64def test_datetime_min_max_iso_format() -> None:

Callers

nothing calls this directly

Calls 2

nowMethod · 0.45
_updateMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…