Changeset 11824 for main/waeup.kofa/trunk/src/waeup/kofa/utils/tests
- Timestamp:
- 26 Sep 2014, 11:53:55 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/utils/tests/test_helpers.py
r11659 r11824 537 537 self.assertEqual(helpers.check_csv_charset(csv), 2) 538 538 539 540 class MemInfoTestCase(unittest.TestCase): 541 542 def test_getsetattrs(self): 543 # we can set/get attributes of MemInfos 544 info = helpers.MemInfo() 545 self.assertRaises( 546 KeyError, info.__getattr__, 'foo') 547 info['foo'] = 'bar' 548 assert info.foo == 'bar' 549 info.bar = 'baz' 550 assert info.bar == 'baz' 551 552 def test_getattrs(self): 553 # we can del attributes 554 info = helpers.MemInfo() 555 info['foo'] = 'bar' 556 del info['foo'] 557 self.assertRaises( 558 KeyError, info.__getattr__, 'foo') 559 info['bar'] = 'baz' 560 del info.bar 561 self.assertRaises( 562 KeyError, info.__getattr__, 'bar') 563 564 565 class GetMemInfoTestCase(unittest.TestCase): 566 567 @unittest.skipIf( 568 not os.path.exists('/proc/meminfo'), 569 reason="No /proc/meminfo found.") 570 def test_system(self): 571 info = helpers.get_meminfo() 572 assert isinstance(info, helpers.MemInfo) 573 574 def test_values(self): 575 sample_meminfo = os.path.join( 576 os.path.dirname(__file__), 'sample_meminfo') 577 info = helpers.get_meminfo(src=sample_meminfo) 578 assert info.Cached == 1013816 579 580 def test_invalid_src(self): 581 # we cope with invalid src files 582 info = helpers.get_meminfo(src="nOt-ExIsTiNg-FiLe") 583 assert info is None 584 585 539 586 def test_suite(): 540 587 suite = unittest.TestSuite() … … 554 601 SimpleHelpersTestCase, 555 602 CheckCSVCharsetTestCase, 603 MemInfoTestCase, 604 GetMemInfoTestCase, 556 605 ]: 557 606 suite.addTests(
Note: See TracChangeset for help on using the changeset viewer.