Skip to content

Commit 3db748d

Browse files
authored
Merge pull request nficano#140 from mwbenowitz/pyyaml-loader-fix
PyYAML loader fix
2 parents b0bd254 + 81044ad commit 3db748d

File tree

5 files changed

+40
-5
lines changed

5 files changed

+40
-5
lines changed

.travis.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
language: python
22
python:
3-
- "2.6"
43
- "2.7"
54
- "3.3"
65
- "3.4"

aws_lambda/aws_lambda.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -752,7 +752,7 @@ def get_concurrency(cfg):
752752

753753

754754
def read_cfg(path_to_config_file, profile_name):
755-
cfg = read(path_to_config_file, loader=yaml.load)
755+
cfg = read(path_to_config_file, loader=yaml.full_load)
756756
if profile_name is not None:
757757
cfg['profile'] = profile_name
758758
elif 'AWS_PROFILE' in os.environ:

tests/dev_requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
bumpversion==0.5.3
22
pre-commit==0.15.0
3-
pytest
3+
pytest>=3.6
44
pytest-cov
55
flake8

tests/unit/test_LambdaContext.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
class TestLambdaContext(unittest.TestCase):
66

77
def test_get_remaining_time_in_millis(self):
8-
context = LambdaContext('function_name',2000)
8+
context = LambdaContext('function_name', 2000)
99
time.sleep(.5)
10-
self.assertTrue(context.get_remaining_time_in_millis() < 2000)
10+
self.assertTrue(context.get_remaining_time_in_millis() < 2000000)
1111

1212

1313
if __name__ == '__main__':

tests/unit/test_readHelper.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import os
2+
import unittest
3+
import yaml
4+
from aws_lambda.helpers import read
5+
6+
7+
class TestReadHelper(unittest.TestCase):
8+
9+
TEST_FILE = 'readTmp.txt'
10+
11+
def setUp(self):
12+
with open(TestReadHelper.TEST_FILE, 'w') as tmp_file:
13+
tmp_file.write('testYaml: testing')
14+
15+
def tearDown(self):
16+
os.remove(TestReadHelper.TEST_FILE)
17+
18+
def test_read_no_loader_non_binary(self):
19+
fileContents = read(TestReadHelper.TEST_FILE)
20+
self.assertEqual(fileContents, 'testYaml: testing')
21+
22+
def test_read_yaml_loader_non_binary(self):
23+
testYaml = read(TestReadHelper.TEST_FILE, loader=yaml.full_load)
24+
self.assertEqual(testYaml['testYaml'], 'testing')
25+
26+
def test_read_no_loader_binary_mode(self):
27+
fileContents = read(TestReadHelper.TEST_FILE, binary_file=True)
28+
self.assertEqual(fileContents, b'testYaml: testing')
29+
30+
def test_read_yaml_loader_binary_mode(self):
31+
testYaml = read(
32+
TestReadHelper.TEST_FILE,
33+
loader=yaml.full_load,
34+
binary_file=True
35+
)
36+
self.assertEqual(testYaml['testYaml'], 'testing')

0 commit comments

Comments
 (0)