• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env python3
2#
3# Copyright 2018 - The Android Open Source Project
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9#     http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16import unittest
17
18from acts import error
19
20
21class ActsErrorTest(unittest.TestCase):
22
23    def test_assert_key_pulled_from_acts_error_code(self):
24        e = error.ActsError()
25        self.assertEqual(e.error_code, 100)
26
27    def test_assert_description_pulled_from_docstring(self):
28        e = error.ActsError()
29        self.assertEqual(e.error_doc, 'Base Acts Error')
30
31    def test_error_without_args(self):
32        e = error.ActsError()
33        self.assertEqual(e.details, '')
34
35    def test_error_with_args(self):
36        args = ('hello', )
37        e = error.ActsError(*args)
38        self.assertEqual(e.details, 'hello')
39
40    def test_error_with_kwargs(self):
41        e = error.ActsError(key='value')
42        self.assertIn(('key', 'value'), e.extras.items())
43
44
45if __name__ == '__main__':
46    unittest.main()
47