1#!/usr/bin/env python2 2# 3# Copyright 2014 Google Inc. All Rights Reserved. 4"""The unittest of flags.""" 5 6from __future__ import print_function 7import test_flag 8 9import unittest 10 11 12class FlagTestCase(unittest.TestCase): 13 """The unittest class.""" 14 15 def test_test_flag(self): 16 # Verify that test_flag.is_test exists, that it is a list, 17 # and that it contains 1 element. 18 self.assertTrue(type(test_flag.is_test) is list) 19 self.assertEqual(len(test_flag.is_test), 1) 20 21 # Verify that the getting the flag works and that the flag 22 # contains False, its starting value. 23 save_flag = test_flag.GetTestMode() 24 self.assertFalse(save_flag) 25 26 # Verify that setting the flat to True, then getting it, works. 27 test_flag.SetTestMode(True) 28 self.assertTrue(test_flag.GetTestMode()) 29 30 # Verify that setting the flag to False, then getting it, works. 31 test_flag.SetTestMode(save_flag) 32 self.assertFalse(test_flag.GetTestMode()) 33 34 # Verify that test_flag.is_test still exists, that it still is a 35 # list, and that it still contains 1 element. 36 self.assertTrue(type(test_flag.is_test) is list) 37 self.assertEqual(len(test_flag.is_test), 1) 38 39 40if __name__ == '__main__': 41 unittest.main() 42