@@ -272,3 +272,41 @@ def test_empty_layout():
272272
273273 fig = plt .gcf ()
274274 fig .tight_layout ()
275+
276+
277+ def test_verybig_decorators_horizontal ():
278+ "Test that warning emitted when xlabel too big"
279+ fig , ax = plt .subplots (figsize = (3 , 2 ))
280+ ax .set_xlabel ('a' * 100 )
281+ with warnings .catch_warnings (record = True ) as w :
282+ fig .tight_layout ()
283+ assert len (w ) == 1
284+
285+
286+ def test_verybig_decorators_vertical ():
287+ "Test that warning emitted when xlabel too big"
288+ fig , ax = plt .subplots (figsize = (3 , 2 ))
289+ ax .set_ylabel ('a' * 100 )
290+ with warnings .catch_warnings (record = True ) as w :
291+ fig .tight_layout ()
292+ assert len (w ) == 1
293+
294+
295+ def test_big_decorators_horizontal ():
296+ "Test that warning emitted when xlabel too big"
297+ fig , axs = plt .subplots (1 , 2 , figsize = (3 , 2 ))
298+ axs [0 ].set_xlabel ('a' * 30 )
299+ axs [1 ].set_xlabel ('b' * 30 )
300+ with warnings .catch_warnings (record = True ) as w :
301+ fig .tight_layout ()
302+ assert len (w ) == 1
303+
304+
305+ def test_big_decorators_vertical ():
306+ "Test that warning emitted when xlabel too big"
307+ fig , axs = plt .subplots (2 , 1 , figsize = (3 , 2 ))
308+ axs [0 ].set_ylabel ('a' * 20 )
309+ axs [1 ].set_ylabel ('b' * 20 )
310+ with warnings .catch_warnings (record = True ) as w :
311+ fig .tight_layout ()
312+ assert len (w ) == 1
0 commit comments