Home | History | Annotate | Download | only in atest
      1 #!/usr/bin/env python
      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.
     16 
     17 """Unittests for atest_utils."""
     18 
     19 import unittest
     20 
     21 import atest_utils
     22 
     23 
     24 #pylint: disable=protected-access
     25 class AtestUtilsUnittests(unittest.TestCase):
     26     """Unit tests for atest_utils.py"""
     27 
     28     def test_capture_fail_section_has_fail_section(self):
     29         """Test capture_fail_section when has fail section."""
     30         test_list = ['AAAAAA', 'FAILED: Error1', '^\n', 'Error2\n',
     31                      '[  6% 191/2997] BBBBBB\n', 'CCCCC',
     32                      '[  20% 322/2997] DDDDDD\n', 'EEEEE']
     33         want_list = ['FAILED: Error1', '^\n', 'Error2\n']
     34         self.assertEqual(want_list,
     35                          atest_utils._capture_fail_section(test_list))
     36 
     37     def test_capture_fail_section_no_fail_section(self):
     38         """Test capture_fail_section when no fail section."""
     39         test_list = ['[ 6% 191/2997] XXXXX', 'YYYYY: ZZZZZ']
     40         want_list = []
     41         self.assertEqual(want_list,
     42                          atest_utils._capture_fail_section(test_list))
     43 
     44 
     45 if __name__ == "__main__":
     46     unittest.main()
     47