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

Skip to content

Commit de2187a

Browse files
authored
Merge pull request #2 from pganssle/rect-timedelta-test
Add a test to ensure that datetimes cannot be used as deltas.
2 parents 4a203d8 + b4ae535 commit de2187a

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

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

0 commit comments

Comments
 (0)