1#!/usr/bin/env python3 2# -*- coding: utf-8 -*- 3# Copyright 2014 The ChromiumOS Authors 4# Use of this source code is governed by a BSD-style license that can be 5# found in the LICENSE file. 6 7"""The unittest of flags.""" 8 9 10import unittest 11 12import test_flag 13 14 15class FlagTestCase(unittest.TestCase): 16 """The unittest class.""" 17 18 def test_test_flag(self): 19 # Verify that test_flag.is_test exists, that it is a list, 20 # and that it contains 1 element. 21 self.assertTrue(isinstance(test_flag.is_test, list)) 22 self.assertEqual(len(test_flag.is_test), 1) 23 24 # Verify that the getting the flag works and that the flag 25 # contains False, its starting value. 26 save_flag = test_flag.GetTestMode() 27 self.assertFalse(save_flag) 28 29 # Verify that setting the flat to True, then getting it, works. 30 test_flag.SetTestMode(True) 31 self.assertTrue(test_flag.GetTestMode()) 32 33 # Verify that setting the flag to False, then getting it, works. 34 test_flag.SetTestMode(save_flag) 35 self.assertFalse(test_flag.GetTestMode()) 36 37 # Verify that test_flag.is_test still exists, that it still is a 38 # list, and that it still contains 1 element. 39 self.assertTrue(isinstance(test_flag.is_test, list)) 40 self.assertEqual(len(test_flag.is_test), 1) 41 42 43if __name__ == "__main__": 44 unittest.main() 45