77
88class CommonBinaryTests (util .CommonTests , unittest .TestCase ):
99 def execute (self , package , path ):
10- with resources .open_binary (package , path ):
11- pass
10+ with util .suppress_known_deprecation ():
11+ with resources .open_binary (package , path ):
12+ pass
1213
1314
1415class CommonTextTests (util .CommonTests , unittest .TestCase ):
1516 def execute (self , package , path ):
16- with resources .open_text (package , path ):
17- pass
17+ with util .suppress_known_deprecation ():
18+ with resources .open_text (package , path ):
19+ pass
1820
1921
2022class OpenTests :
2123 def test_open_binary (self ):
22- with resources .open_binary (self .data , 'binary.file' ) as fp :
23- result = fp .read ()
24- self .assertEqual (result , b'\x00 \x01 \x02 \x03 ' )
24+ with util .suppress_known_deprecation ():
25+ with resources .open_binary (self .data , 'binary.file' ) as fp :
26+ result = fp .read ()
27+ self .assertEqual (result , b'\x00 \x01 \x02 \x03 ' )
2528
2629 def test_open_text_default_encoding (self ):
27- with resources .open_text (self .data , 'utf-8.file' ) as fp :
28- result = fp .read ()
30+ with util .suppress_known_deprecation ():
31+ with resources .open_text (self .data , 'utf-8.file' ) as fp :
32+ result = fp .read ()
2933 self .assertEqual (result , 'Hello, UTF-8 world!\n ' )
3034
3135 def test_open_text_given_encoding (self ):
32- with resources .open_text (self .data , 'utf-16.file' , 'utf-16' , 'strict' ) as fp :
33- result = fp .read ()
36+ with util .suppress_known_deprecation ():
37+ with resources .open_text (
38+ self .data , 'utf-16.file' , 'utf-16' , 'strict'
39+ ) as fp :
40+ result = fp .read ()
3441 self .assertEqual (result , 'Hello, UTF-16 world!\n ' )
3542
3643 def test_open_text_with_errors (self ):
3744 # Raises UnicodeError without the 'errors' argument.
38- with resources .open_text (self .data , 'utf-16.file' , 'utf-8' , 'strict' ) as fp :
39- self .assertRaises (UnicodeError , fp .read )
40- with resources .open_text (self .data , 'utf-16.file' , 'utf-8' , 'ignore' ) as fp :
41- result = fp .read ()
45+ with util .suppress_known_deprecation ():
46+ with resources .open_text (self .data , 'utf-16.file' , 'utf-8' , 'strict' ) as fp :
47+ self .assertRaises (UnicodeError , fp .read )
48+ with util .suppress_known_deprecation ():
49+ with resources .open_text (self .data , 'utf-16.file' , 'utf-8' , 'ignore' ) as fp :
50+ result = fp .read ()
4251 self .assertEqual (
4352 result ,
4453 'H\x00 e\x00 l\x00 l\x00 o\x00 ,\x00 '
@@ -47,14 +56,16 @@ def test_open_text_with_errors(self):
4756 )
4857
4958 def test_open_binary_FileNotFoundError (self ):
50- self .assertRaises (
51- FileNotFoundError , resources .open_binary , self .data , 'does-not-exist'
52- )
59+ with util .suppress_known_deprecation ():
60+ self .assertRaises (
61+ FileNotFoundError , resources .open_binary , self .data , 'does-not-exist'
62+ )
5363
5464 def test_open_text_FileNotFoundError (self ):
55- self .assertRaises (
56- FileNotFoundError , resources .open_text , self .data , 'does-not-exist'
57- )
65+ with util .suppress_known_deprecation ():
66+ self .assertRaises (
67+ FileNotFoundError , resources .open_text , self .data , 'does-not-exist'
68+ )
5869
5970
6071class OpenDiskTests (OpenTests , unittest .TestCase ):
0 commit comments