• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env python3
2# -*- coding: utf-8 -*-
3# Copyright 2014 The Chromium OS Authors. All rights reserved.
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
9from __future__ import print_function
10
11import unittest
12
13import test_flag
14
15
16class FlagTestCase(unittest.TestCase):
17  """The unittest class."""
18
19  def test_test_flag(self):
20    # Verify that test_flag.is_test exists, that it is a list,
21    # and that it contains 1 element.
22    self.assertTrue(isinstance(test_flag.is_test, list))
23    self.assertEqual(len(test_flag.is_test), 1)
24
25    # Verify that the getting the flag works and that the flag
26    # contains False, its starting value.
27    save_flag = test_flag.GetTestMode()
28    self.assertFalse(save_flag)
29
30    # Verify that setting the flat to True, then getting it, works.
31    test_flag.SetTestMode(True)
32    self.assertTrue(test_flag.GetTestMode())
33
34    # Verify that setting the flag to False, then getting it, works.
35    test_flag.SetTestMode(save_flag)
36    self.assertFalse(test_flag.GetTestMode())
37
38    # Verify that test_flag.is_test still exists, that it still is a
39    # list, and that it still contains 1 element.
40    self.assertTrue(isinstance(test_flag.is_test, list))
41    self.assertEqual(len(test_flag.is_test), 1)
42
43
44if __name__ == '__main__':
45  unittest.main()
46