Skip to content

Commit 03fba6b

Browse files
pganssledstansby
authored andcommitted
Add a test to ensure that datetimes cannot be used as deltas.
1 parent 8208ddc commit 03fba6b

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

lib/matplotlib/tests/test_patches.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,3 +374,16 @@ def test_datetime_rectangle():
374374

375375
fig, ax = plt.subplots()
376376
ax.add_patch(patch)
377+
378+
379+
def test_datetime_datetime_fails():
380+
from datetime import datetime
381+
382+
start = datetime(2017, 1, 1, 0, 0, 0)
383+
dt_delta = datetime(1970, 1, 5) # Will be 5 days if units are done wrong
384+
385+
with pytest.raises(TypeError):
386+
mpatches.Rectangle((start, 0), dt_delta, 1)
387+
388+
with pytest.raises(TypeError):
389+
mpatches.Rectangle((0, start), 1, dt_delta)

0 commit comments

Comments
 (0)