Changeset 9372 for main/waeup.kofa/trunk/src/waeup
- Timestamp:
- 21 Oct 2012, 10:43:54 (12 years ago)
- Location:
- main/waeup.kofa/trunk/src/waeup/kofa/utils
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/utils/helpers.py
r9043 r9372 685 685 writer.writerow(row) 686 686 return tmp_path 687 688 def product(sequence, start=1): 689 """Returns the product of a sequence of numbers (_not_ strings) 690 multiplied by the parameter `start` (defaults to 1). If the 691 sequence is empty, returns 0. 692 """ 693 if not len(sequence): 694 return 0 695 result = start 696 for item in sequence: 697 result *= item 698 return result -
main/waeup.kofa/trunk/src/waeup/kofa/utils/tests/test_helpers.py
r8632 r9372 39 39 implements(IFakeObject) 40 40 41 class SimpleHelpersTestCase(unittest.TestCase): 42 # Tests for simple functions in `helpers`. 43 def test_product(self): 44 # the product will return zero without input 45 result1 = helpers.product([]) 46 result2 = helpers.product([1,2,3]) 47 result3 = helpers.product([], start=5) 48 result4 = helpers.product([1,2,3], start=5) 49 self.assertEqual(result1, 0) 50 self.assertEqual(result2, 6) 51 self.assertEqual(result3, 0) 52 self.assertEqual(result4, 30) 53 return 54 41 55 class RemoveFileOrDirectoryTestCase(unittest.TestCase): 42 56 … … 447 461 contents, '\r\n') 448 462 return 463 449 464 450 465 def test_suite(): … … 463 478 GetFileFormatTestCase, 464 479 MergeCSVFileTestCase, 480 SimpleHelpersTestCase, 465 481 ]: 466 482 suite.addTests(
Note: See TracChangeset for help on using the changeset viewer.