| 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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 | 69 |
| 70 def fake_executive(output=None): | 70 def fake_executive(output=None): |
| 71 if output: | 71 if output: |
| 72 return MockExecutive2(output=output) | 72 return MockExecutive2(output=output) |
| 73 return MockExecutive2(exception=SystemError) | 73 return MockExecutive2(exception=SystemError) |
| 74 | 74 |
| 75 | 75 |
| 76 class TestPlatformInfo(unittest.TestCase): | 76 class TestPlatformInfo(unittest.TestCase): |
| 77 | 77 |
| 78 def make_info(self, sys_module=None, platform_module=None, filesystem_module
=None, executive=None): | 78 def make_info(self, sys_module=None, platform_module=None, filesystem_module
=None, executive=None): |
| 79 return PlatformInfo(sys_module or fake_sys(), platform_module or fake_pl
atform(), filesystem_module or MockFileSystem(), executive or fake_executive()) | 79 return PlatformInfo(sys_module or fake_sys(), platform_module or fake_pl
atform(), |
| 80 filesystem_module or MockFileSystem(), executive or
fake_executive()) |
| 80 | 81 |
| 81 def test_real_code(self): | 82 def test_real_code(self): |
| 82 # This test makes sure the real (unmocked) code actually works. | 83 # This test makes sure the real (unmocked) code actually works. |
| 83 info = PlatformInfo(sys, platform, FileSystem(), Executive()) | 84 info = PlatformInfo(sys, platform, FileSystem(), Executive()) |
| 84 self.assertNotEquals(info.os_name, '') | 85 self.assertNotEquals(info.os_name, '') |
| 85 self.assertNotEquals(info.os_version, '') | 86 self.assertNotEquals(info.os_version, '') |
| 86 self.assertNotEquals(info.display_name(), '') | 87 self.assertNotEquals(info.display_name(), '') |
| 87 self.assertTrue(info.is_mac() or info.is_win() or info.is_linux() or inf
o.is_freebsd()) | 88 self.assertTrue(info.is_mac() or info.is_win() or info.is_linux() or inf
o.is_freebsd()) |
| 88 self.assertIsNotNone(info.terminal_width()) | 89 self.assertIsNotNone(info.terminal_width()) |
| 89 | 90 |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 self.assertEqual(info.total_bytes_memory(), 1234) | 210 self.assertEqual(info.total_bytes_memory(), 1234) |
| 210 | 211 |
| 211 info = self.make_info(fake_sys('win32', tuple([6, 1, 7600]))) | 212 info = self.make_info(fake_sys('win32', tuple([6, 1, 7600]))) |
| 212 self.assertIsNone(info.total_bytes_memory()) | 213 self.assertIsNone(info.total_bytes_memory()) |
| 213 | 214 |
| 214 info = self.make_info(fake_sys('linux2')) | 215 info = self.make_info(fake_sys('linux2')) |
| 215 self.assertIsNone(info.total_bytes_memory()) | 216 self.assertIsNone(info.total_bytes_memory()) |
| 216 | 217 |
| 217 info = self.make_info(fake_sys('freebsd9')) | 218 info = self.make_info(fake_sys('freebsd9')) |
| 218 self.assertIsNone(info.total_bytes_memory()) | 219 self.assertIsNone(info.total_bytes_memory()) |
| OLD | NEW |