7
7
8
8
class CommonBinaryTests (util .CommonTests , unittest .TestCase ):
9
9
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
12
13
13
14
14
15
class CommonTextTests (util .CommonTests , unittest .TestCase ):
15
16
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
18
20
19
21
20
22
class OpenTests :
21
23
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 ' )
25
28
26
29
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 ()
29
33
self .assertEqual (result , 'Hello, UTF-8 world!\n ' )
30
34
31
35
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 ()
34
41
self .assertEqual (result , 'Hello, UTF-16 world!\n ' )
35
42
36
43
def test_open_text_with_errors (self ):
37
44
# 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 ()
42
51
self .assertEqual (
43
52
result ,
44
53
'H\x00 e\x00 l\x00 l\x00 o\x00 ,\x00 '
@@ -47,14 +56,16 @@ def test_open_text_with_errors(self):
47
56
)
48
57
49
58
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
+ )
53
63
54
64
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
+ )
58
69
59
70
60
71
class OpenDiskTests (OpenTests , unittest .TestCase ):
0 commit comments