MCPcopy Index your code
hub / github.com/plotly/plotly.py / test_timeline

Function test_timeline

tests/test_optional/test_px/test_px_functions.py:600–623  ·  view source on GitHub ↗
(constructor)

Source from the content-addressed store, hash-verified

598
599
600def test_timeline(constructor):
601 df = constructor(
602 {
603 "Task": ["Job A", "Job B", "Job C"],
604 "Start": ["2009-01-01", "2009-03-05", "2009-02-20"],
605 "Finish": ["2009-02-28", "2009-04-15", "2009-05-30"],
606 }
607 )
608 fig = px.timeline(df, x_start="Start", x_end="Finish", y="Task", color="Task")
609 assert len(fig.data) == 3
610 assert fig.layout.xaxis.type == "date"
611 assert fig.layout.xaxis.title.text is None
612 fig = px.timeline(df, x_start="Start", x_end="Finish", y="Task", facet_row="Task")
613 assert len(fig.data) == 3
614 assert fig.data[1].xaxis == "x2"
615 assert fig.layout.xaxis.type == "date"
616
617 msg = "Both x_start and x_end are required"
618 with pytest.raises(ValueError, match=msg):
619 px.timeline(df, x_start="Start", y="Task", color="Task")
620
621 msg = "Both x_start and x_end must refer to data convertible to datetimes."
622 with pytest.raises(TypeError, match=msg):
623 px.timeline(df, x_start="Start", x_end=["a", "b", "c"], y="Task", color="Task")
624
625
626@pytest.mark.parametrize(

Callers

nothing calls this directly

Calls 1

constructorFunction · 0.85

Tested by

no test coverage detected