99import matplotlib .pyplot as plt
1010from matplotlib .testing .decorators import image_comparison , cleanup
1111
12- from nose . tools import assert_raises
12+ import pytest
1313
1414
1515def check_shared (axs , x_shared , y_shared ):
@@ -105,17 +105,22 @@ def test_shared():
105105@cleanup
106106def test_exceptions ():
107107 # TODO should this test more options?
108- assert_raises (ValueError , plt .subplots , 2 , 2 , sharex = 'blah' )
109- assert_raises (ValueError , plt .subplots , 2 , 2 , sharey = 'blah' )
108+ with pytest .raises (ValueError ):
109+ plt .subplots (2 , 2 , sharex = 'blah' )
110+ with pytest .raises (ValueError ):
111+ plt .subplots (2 , 2 , sharey = 'blah' )
110112 # We filter warnings in this test which are genuine since
111113 # the point of this test is to ensure that this raises.
112114 with warnings .catch_warnings ():
113115 warnings .filterwarnings ('ignore' ,
114116 message = '.*sharex\ argument\ to\ subplots' ,
115117 category = UserWarning )
116- assert_raises (ValueError , plt .subplots , 2 , 2 , - 1 )
117- assert_raises (ValueError , plt .subplots , 2 , 2 , 0 )
118- assert_raises (ValueError , plt .subplots , 2 , 2 , 5 )
118+ with pytest .raises (ValueError ):
119+ plt .subplots (2 , 2 , - 1 )
120+ with pytest .raises (ValueError ):
121+ plt .subplots (2 , 2 , 0 )
122+ with pytest .raises (ValueError ):
123+ plt .subplots (2 , 2 , 5 )
119124
120125
121126@image_comparison (baseline_images = ['subplots_offset_text' ], remove_text = False )
@@ -127,8 +132,3 @@ def test_subplots_offsettext():
127132 axes [1 , 0 ].plot (x , x )
128133 axes [0 , 1 ].plot (y , x )
129134 axes [1 , 1 ].plot (y , x )
130-
131-
132- if __name__ == "__main__" :
133- import nose
134- nose .runmodule (argv = ['-s' , '--with-doctest' ], exit = False )
0 commit comments