forked from aws/aws-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_utils.py
More file actions
29 lines (22 loc) · 781 Bytes
/
test_utils.py
File metadata and controls
29 lines (22 loc) · 781 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import os
import tempfile
import shutil
import codecs
from awscli.testutils import unittest
from awscli.utils import write_exception
class TestWriteException(unittest.TestCase):
def setUp(self):
self.tempdir = tempfile.mkdtemp()
self.outfile = os.path.join(self.tempdir, 'stdout')
def tearDown(self):
shutil.rmtree(self.tempdir)
def test_write_exception(self):
error_message = "Some error message."
ex = Exception(error_message)
with codecs.open(self.outfile, 'w+', encoding='utf-8') as outfile:
write_exception(ex, outfile)
outfile.seek(0)
expected_output = (
"\n%s\n" % error_message
)
self.assertEqual(outfile.read(), expected_output)