1
1
import os
2
2
import unittest
3
3
import yaml
4
- from yaml import YAMLLoadWarning
5
4
from aws_lambda .helpers import read
6
5
6
+
7
7
class TestReadHelper (unittest .TestCase ):
8
8
9
9
TEST_FILE = 'readTmp.txt'
10
10
11
11
def setUp (self ):
12
12
with open (TestReadHelper .TEST_FILE , 'w' ) as tmp_file :
13
13
tmp_file .write ('testYaml: testing' )
14
-
14
+
15
15
def tearDown (self ):
16
16
os .remove (TestReadHelper .TEST_FILE )
17
-
17
+
18
18
def test_read_no_loader_non_binary (self ):
19
19
fileContents = read (TestReadHelper .TEST_FILE )
20
20
self .assertEqual (fileContents , 'testYaml: testing' )
21
-
21
+
22
22
def test_read_yaml_loader_non_binary (self ):
23
23
testYaml = read (TestReadHelper .TEST_FILE , loader = yaml .full_load )
24
24
self .assertEqual (testYaml ['testYaml' ], 'testing' )
25
-
25
+
26
26
def test_read_no_loader_binary_mode (self ):
27
27
fileContents = read (TestReadHelper .TEST_FILE , binary_file = True )
28
28
self .assertEqual (fileContents , b'testYaml: testing' )
29
-
29
+
30
30
def test_read_yaml_loader_binary_mode (self ):
31
31
testYaml = read (
32
32
TestReadHelper .TEST_FILE ,
33
33
loader = yaml .full_load ,
34
34
binary_file = True
35
35
)
36
36
self .assertEqual (testYaml ['testYaml' ], 'testing' )
37
-
38
- def test_read_yaml_old_load_warns (self ):
39
- with self .assertWarns (YAMLLoadWarning ):
40
- testYaml = read (TestReadHelper .TEST_FILE , loader = yaml .load )
41
- self .assertEqual (testYaml ['testYaml' ], 'testing' )
0 commit comments