File: test_exceptions.py

package info (click to toggle)
aws-crt-python 0.16.8%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 78,328 kB
  • sloc: ansic: 330,743; python: 18,949; makefile: 6,271; sh: 3,712; asm: 754; cpp: 699; ruby: 208; java: 77; perl: 73; javascript: 46; xml: 11
file content (23 lines) | stat: -rw-r--r-- 819 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0.

import awscrt.exceptions
import unittest


class AwsCrtErrorTest(unittest.TestCase):
    def test_error_code_conversion(self):
        err = awscrt.exceptions.from_code(0)
        self.assertEqual(0, err.code)
        self.assertEqual("AWS_ERROR_SUCCESS", err.name)
        self.assertTrue("success" in err.message.lower())

    def test_error_code_remaps_to_corresponding_builtins(self):
        err = awscrt.exceptions.from_code(1)
        self.assertEqual(MemoryError, type(err))

    def test_bad_error_code_wont_crash(self):
        err = awscrt.exceptions.from_code(999999999)
        self.assertEqual(999999999, err.code)
        self.assertIsNotNone(err.name)
        self.assertIsNotNone(err.message)