• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env python2
2#
3# Copyright 2014 Google Inc. All Rights Reserved.
4
5"""The unittest of flags."""
6
7from __future__ import print_function
8import test_flag
9
10import unittest
11
12
13class FlagTestCase(unittest.TestCase):
14  """The unittest class."""
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