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)
def from_invalid_string3(): YearMonth.from_string('xyz')
def from_invalid_string2(): YearMonth.from_string('2012-1')
def from_invalid_string1(): YearMonth.from_string('2012-01-')