예제 #1
0
	def testFromString(self):
		ym = YearMonth.from_string('2011-12')
		self.assertEquals(ym, self.ym201112)
		
		ym = YearMonth.from_string('2012-01')
		self.assertEquals(ym, self.ym201201)
		
		ym = YearMonth.from_string('2012-06')
		self.assertEquals(ym, self.ym201206a)

		def from_invalid_string1():
			YearMonth.from_string('2012-01-')
		self.assertRaises(ValueError, from_invalid_string1)

		def from_invalid_string2():
			YearMonth.from_string('2012-1')
		self.assertRaises(ValueError, from_invalid_string2)

		def from_invalid_string3():
			YearMonth.from_string('xyz')
		self.assertRaises(ValueError, from_invalid_string3)
예제 #2
0
		def from_invalid_string3():
			YearMonth.from_string('xyz')
예제 #3
0
		def from_invalid_string2():
			YearMonth.from_string('2012-1')
예제 #4
0
		def from_invalid_string1():
			YearMonth.from_string('2012-01-')