Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 521754f

Browse files
pganssledstansby
authored andcommitted
Add a test to ensure that datetimes cannot be used as deltas.
1 parent 71b9568 commit 521754f

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
@@ -377,3 +377,16 @@ def test_datetime_rectangle():
377377

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

0 commit comments

Comments
 (0)