示例#1
0
	def testParsePositiveInt(self):
		# Test for illegal values:
		try:
			Helpers.parsePositiveInt("abc")
		except ValueError:
			pass
		else:
			self.fail("Should raise ValueError when called with a non-number!")
		try:
			Helpers.parsePositiveInt(-5)
		except ValueError:
			pass
		else:
			self.fail("Should raise ValueError when called with a negative number!")
		try:
			Helpers.parsePositiveInt(0)
		except ValueError:
			pass
		else:
			self.fail("Should raise ValueError when called with zero!")
		# Test for legal values:
		testValues = { 5:5, 7.3:7, 7.9:7 }
		for val in testValues.items():
			self.assertEqual(Helpers.parsePositiveInt(val[0]), val[1])