OLD | NEW |
1 # Copyright (C) 2011 Google Inc. All rights reserved. | 1 # Copyright (C) 2011 Google Inc. All rights reserved. |
2 # | 2 # |
3 # Redistribution and use in source and binary forms, with or without | 3 # Redistribution and use in source and binary forms, with or without |
4 # modification, are permitted provided that the following conditions are | 4 # modification, are permitted provided that the following conditions are |
5 # met: | 5 # met: |
6 # | 6 # |
7 # * Redistributions of source code must retain the above copyright | 7 # * Redistributions of source code must retain the above copyright |
8 # notice, this list of conditions and the following disclaimer. | 8 # notice, this list of conditions and the following disclaimer. |
9 # * Redistributions in binary form must reproduce the above | 9 # * Redistributions in binary form must reproduce the above |
10 # copyright notice, this list of conditions and the following disclaimer | 10 # copyright notice, this list of conditions and the following disclaimer |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 def fake_executive(output=None): | 63 def fake_executive(output=None): |
64 if output: | 64 if output: |
65 return MockExecutive2(output=output) | 65 return MockExecutive2(output=output) |
66 return MockExecutive2(exception=SystemError) | 66 return MockExecutive2(exception=SystemError) |
67 | 67 |
68 | 68 |
69 class TestPlatformInfo(unittest.TestCase): | 69 class TestPlatformInfo(unittest.TestCase): |
70 def make_info(self, sys_module=None, platform_module=None, executive=None): | 70 def make_info(self, sys_module=None, platform_module=None, executive=None): |
71 return PlatformInfo(sys_module or fake_sys(), platform_module or fake_pl
atform(), executive or fake_executive()) | 71 return PlatformInfo(sys_module or fake_sys(), platform_module or fake_pl
atform(), executive or fake_executive()) |
72 | 72 |
73 # FIXME: This should be called integration_test_real_code(), but integration
tests aren't | |
74 # yet run by default and there's no reason not to run this everywhere by def
ault. | |
75 def test_real_code(self): | 73 def test_real_code(self): |
76 # This test makes sure the real (unmocked) code actually works. | 74 # This test makes sure the real (unmocked) code actually works. |
77 info = PlatformInfo(sys, platform, Executive()) | 75 info = PlatformInfo(sys, platform, Executive()) |
78 self.assertNotEquals(info.os_name, '') | 76 self.assertNotEquals(info.os_name, '') |
79 self.assertNotEquals(info.os_version, '') | 77 self.assertNotEquals(info.os_version, '') |
80 self.assertNotEquals(info.display_name(), '') | 78 self.assertNotEquals(info.display_name(), '') |
81 self.assertTrue(info.is_mac() or info.is_win() or info.is_linux() or inf
o.is_freebsd()) | 79 self.assertTrue(info.is_mac() or info.is_win() or info.is_linux() or inf
o.is_freebsd()) |
82 self.assertIsNotNone(info.terminal_width()) | 80 self.assertIsNotNone(info.terminal_width()) |
83 | 81 |
84 if info.is_mac(): | 82 if info.is_mac(): |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 self.assertEqual(info.total_bytes_memory(), 1234) | 171 self.assertEqual(info.total_bytes_memory(), 1234) |
174 | 172 |
175 info = self.make_info(fake_sys('win32', tuple([6, 1, 7600]))) | 173 info = self.make_info(fake_sys('win32', tuple([6, 1, 7600]))) |
176 self.assertIsNone(info.total_bytes_memory()) | 174 self.assertIsNone(info.total_bytes_memory()) |
177 | 175 |
178 info = self.make_info(fake_sys('linux2')) | 176 info = self.make_info(fake_sys('linux2')) |
179 self.assertIsNone(info.total_bytes_memory()) | 177 self.assertIsNone(info.total_bytes_memory()) |
180 | 178 |
181 info = self.make_info(fake_sys('freebsd9')) | 179 info = self.make_info(fake_sys('freebsd9')) |
182 self.assertIsNone(info.total_bytes_memory()) | 180 self.assertIsNone(info.total_bytes_memory()) |
OLD | NEW |