@@ -244,9 +244,8 @@ def test_list_currencies():
244244 assert isinstance (list_currencies (locale = 'fr' ), set )
245245 assert list_currencies ('fr' ).issuperset (['BAD' , 'BAM' , 'KRO' ])
246246
247- with pytest .raises (ValueError ) as excinfo :
247+ with pytest .raises (ValueError , match = "expected only letters, got 'yo!'" ) :
248248 list_currencies ('yo!' )
249- assert excinfo .value .args [0 ] == "expected only letters, got 'yo!'"
250249
251250 assert list_currencies (locale = 'pa_Arab' ) == {'PKR' , 'INR' , 'EUR' }
252251
@@ -256,9 +255,8 @@ def test_list_currencies():
256255def test_validate_currency ():
257256 validate_currency ('EUR' )
258257
259- with pytest .raises (UnknownCurrencyError ) as excinfo :
258+ with pytest .raises (UnknownCurrencyError , match = "Unknown currency 'FUU'." ) :
260259 validate_currency ('FUU' )
261- assert excinfo .value .args [0 ] == "Unknown currency 'FUU'."
262260
263261
264262def test_is_currency ():
@@ -514,10 +512,8 @@ def test_format_currency_format_type():
514512 format_type = "accounting" )
515513 == '$0.00' )
516514
517- with pytest .raises (numbers .UnknownCurrencyFormatError ) as excinfo :
518- numbers .format_currency (1099.98 , 'USD' , locale = 'en_US' ,
519- format_type = 'unknown' )
520- assert excinfo .value .args [0 ] == "'unknown' is not a known currency format type"
515+ with pytest .raises (numbers .UnknownCurrencyFormatError , match = "'unknown' is not a known currency format type" ):
516+ numbers .format_currency (1099.98 , 'USD' , locale = 'en_US' , format_type = 'unknown' )
521517
522518 assert (numbers .format_currency (1099.98 , 'JPY' , locale = 'en_US' )
523519 == '\xa5 1,100' )
@@ -757,9 +753,8 @@ def test_parse_number():
757753 assert numbers .parse_number ('1.099' , locale = 'de_DE' ) == 1099
758754 assert numbers .parse_number ('1٬099' , locale = 'ar_EG' , numbering_system = "default" ) == 1099
759755
760- with pytest .raises (numbers .NumberFormatError ) as excinfo :
756+ with pytest .raises (numbers .NumberFormatError , match = "'1.099,98' is not a valid number" ) :
761757 numbers .parse_number ('1.099,98' , locale = 'de' )
762- assert excinfo .value .args [0 ] == "'1.099,98' is not a valid number"
763758
764759 with pytest .raises (numbers .UnsupportedNumberingSystemError ):
765760 numbers .parse_number ('1.099,98' , locale = 'en' , numbering_system = "unsupported" )
@@ -778,9 +773,8 @@ def test_parse_decimal():
778773 == decimal .Decimal ('1099.98' ))
779774 assert numbers .parse_decimal ('1.099,98' , locale = 'de' ) == decimal .Decimal ('1099.98' )
780775
781- with pytest .raises (numbers .NumberFormatError ) as excinfo :
776+ with pytest .raises (numbers .NumberFormatError , match = "'2,109,998' is not a valid decimal number" ) :
782777 numbers .parse_decimal ('2,109,998' , locale = 'de' )
783- assert excinfo .value .args [0 ] == "'2,109,998' is not a valid decimal number"
784778
785779
786780@pytest .mark .parametrize ('string' , [
0 commit comments