@@ -585,12 +585,12 @@ def test_overflow(self):
585
585
586
586
def test_small_long_encode_decode (self ):
587
587
encoded1 = BSON .encode ({'x' : 256 })
588
- decoded1 = BSON .decode (encoded1 )['x' ]
588
+ decoded1 = BSON ( encoded1 ) .decode ()['x' ]
589
589
self .assertEqual (256 , decoded1 )
590
590
self .assertEqual (type (256 ), type (decoded1 ))
591
591
592
592
encoded2 = BSON .encode ({'x' : Int64 (256 )})
593
- decoded2 = BSON .decode (encoded2 )['x' ]
593
+ decoded2 = BSON ( encoded2 ) .decode ()['x' ]
594
594
expected = Int64 (256 )
595
595
self .assertEqual (expected , decoded2 )
596
596
self .assertEqual (type (expected ), type (decoded2 ))
@@ -956,63 +956,63 @@ def test_unicode_decode_error_handler(self):
956
956
replaced_key = b'ke\xe9 str' .decode ('utf-8' , 'replace' )
957
957
ignored_key = b'ke\xe9 str' .decode ('utf-8' , 'ignore' )
958
958
959
- dec = BSON .decode (invalid_key , CodecOptions (
959
+ dec = BSON ( invalid_key ) .decode (CodecOptions (
960
960
unicode_decode_error_handler = "replace" ))
961
961
self .assertEqual (dec , {replaced_key : u"foobar" })
962
962
963
- dec = BSON .decode (invalid_key , CodecOptions (
963
+ dec = BSON ( invalid_key ) .decode (CodecOptions (
964
964
unicode_decode_error_handler = "ignore" ))
965
965
self .assertEqual (dec , {ignored_key : u"foobar" })
966
966
967
- self .assertRaises (InvalidBSON , BSON .decode , invalid_key , CodecOptions (
967
+ self .assertRaises (InvalidBSON , BSON ( invalid_key ) .decode , CodecOptions (
968
968
unicode_decode_error_handler = "strict" ))
969
- self .assertRaises (InvalidBSON , BSON .decode , invalid_key ,
969
+ self .assertRaises (InvalidBSON , BSON ( invalid_key ) .decode ,
970
970
CodecOptions ())
971
- self .assertRaises (InvalidBSON , BSON .decode , invalid_key )
971
+ self .assertRaises (InvalidBSON , BSON ( invalid_key ) .decode )
972
972
973
973
# Test handing of bad string value.
974
974
invalid_val = BSON (enc [:18 ] + b'\xe9 ' + enc [19 :])
975
975
replaced_val = b'fo\xe9 bar' .decode ('utf-8' , 'replace' )
976
976
ignored_val = b'fo\xe9 bar' .decode ('utf-8' , 'ignore' )
977
977
978
- dec = BSON .decode (invalid_val , CodecOptions (
978
+ dec = BSON ( invalid_val ) .decode (CodecOptions (
979
979
unicode_decode_error_handler = "replace" ))
980
980
self .assertEqual (dec , {u"keystr" : replaced_val })
981
981
982
- dec = BSON .decode (invalid_val , CodecOptions (
982
+ dec = BSON ( invalid_val ) .decode (CodecOptions (
983
983
unicode_decode_error_handler = "ignore" ))
984
984
self .assertEqual (dec , {u"keystr" : ignored_val })
985
985
986
- self .assertRaises (InvalidBSON , BSON .decode , invalid_val , CodecOptions (
986
+ self .assertRaises (InvalidBSON , BSON ( invalid_val ) .decode , CodecOptions (
987
987
unicode_decode_error_handler = "strict" ))
988
- self .assertRaises (InvalidBSON , BSON .decode , invalid_val ,
988
+ self .assertRaises (InvalidBSON , BSON ( invalid_val ) .decode ,
989
989
CodecOptions ())
990
- self .assertRaises (InvalidBSON , BSON .decode , invalid_val )
990
+ self .assertRaises (InvalidBSON , BSON ( invalid_val ) .decode )
991
991
992
992
# Test handing bad key + bad value.
993
993
invalid_both = BSON (
994
994
enc [:7 ] + b'\xe9 ' + enc [8 :18 ] + b'\xe9 ' + enc [19 :])
995
995
996
- dec = BSON .decode (invalid_both , CodecOptions (
996
+ dec = BSON ( invalid_both ) .decode (CodecOptions (
997
997
unicode_decode_error_handler = "replace" ))
998
998
self .assertEqual (dec , {replaced_key : replaced_val })
999
999
1000
- dec = BSON .decode (invalid_both , CodecOptions (
1000
+ dec = BSON ( invalid_both ) .decode (CodecOptions (
1001
1001
unicode_decode_error_handler = "ignore" ))
1002
1002
self .assertEqual (dec , {ignored_key : ignored_val })
1003
1003
1004
- self .assertRaises (InvalidBSON , BSON .decode , invalid_both , CodecOptions (
1004
+ self .assertRaises (InvalidBSON , BSON ( invalid_both ) .decode , CodecOptions (
1005
1005
unicode_decode_error_handler = "strict" ))
1006
- self .assertRaises (InvalidBSON , BSON .decode , invalid_both ,
1006
+ self .assertRaises (InvalidBSON , BSON ( invalid_both ) .decode ,
1007
1007
CodecOptions ())
1008
- self .assertRaises (InvalidBSON , BSON .decode , invalid_both )
1008
+ self .assertRaises (InvalidBSON , BSON ( invalid_both ) .decode )
1009
1009
1010
1010
# Test handling bad error mode.
1011
- dec = BSON .decode (enc , CodecOptions (
1011
+ dec = BSON ( enc ) .decode (CodecOptions (
1012
1012
unicode_decode_error_handler = "junk" ))
1013
1013
self .assertEqual (dec , {"keystr" : "foobar" })
1014
1014
1015
- self .assertRaises (InvalidBSON , BSON .decode , invalid_both ,
1015
+ self .assertRaises (InvalidBSON , BSON ( invalid_both ) .decode ,
1016
1016
CodecOptions (unicode_decode_error_handler = "junk" ))
1017
1017
1018
1018
0 commit comments