@@ -57,24 +57,29 @@ def test_run_by_monthly_unit(self):
5757
5858class TestIrregularCase (TestApplication ):
5959 def test_initialize_with_invalid_username (self ):
60- with self .assertRaises (ValueError , msg = 'InvalidUsername is NOT a permitted username.' ) :
60+ with self .assertRaises (ValueError ) as cm :
6161 Application (username = 'InvalidUsername' , unit = 'foobar' , year = self .year ).run ()
62+ self .assertEqual ('InvalidUsername is NOT a permitted username.' , str (cm .exception ))
6263
6364 def test_initialize_with_invalid_unit (self ):
64- with self .assertRaises (ValueError , msg = 'Provide d, w or m as a valid unit.' ) :
65+ with self .assertRaises (ValueError ) as cm :
6566 Application (username = self .username , unit = 'foobar' , year = self .year ).run ()
67+ self .assertEqual ('Provide d, w or m as a valid unit.' , str (cm .exception ))
6668
6769 def test_initialize_with_non_digit_argument (self ):
68- with self .assertRaises (ValueError , msg = 'invalid literal for int() with base 10: "foobar"' ) :
70+ with self .assertRaises (ValueError ) as cm :
6971 Application (username = self .username , year = 'foobar' )
72+ self .assertEqual ('invalid literal for int() with base 10: \' foobar\' ' , str (cm .exception ))
7073
7174 def test_initialize_with_invalid_value_as_year (self ):
72- with self .assertRaises (ValueError , msg = 'Year must be 4 digits.' ) :
75+ with self .assertRaises (ValueError ) as cm :
7376 Application (username = self .username , year = '20233' )
77+ self .assertEqual ('Year must be 4 digits.' , str (cm .exception ))
7478
7579 def test_initialize_with_older_year (self ):
76- with self .assertRaises (ValueError , msg = 'Provide newer than or equal to the current year.' ) :
80+ with self .assertRaises (ValueError ) as cm :
7781 Application (username = self .username , year = '2022' )
82+ self .assertEqual ('Provide newer than or equal to the current year.' , str (cm .exception ))
7883
7984if __name__ == '__main__' :
8085 unittest .main ()
0 commit comments