示例#1
0
 def test_years_hours_and_minutes(self):
     obj = amazonndt.AmazonDuration("P2YT3H10M")
     self.assertEqual(dt.timedelta(weeks=2 * 52, hours=3, minutes=10),
                      obj.timedelta)
示例#2
0
 def test_all_values(self):
     obj = amazonndt.AmazonDuration("P3Y4M2W1DT5H10M42S")
示例#3
0
 def test_months(self):
     obj = amazonndt.AmazonDuration("P4M")
     self.assertEqual(dt.timedelta(weeks=16), obj.timedelta)
示例#4
0
 def test_hours_and_minutes(self):
     obj = amazonndt.AmazonDuration("PT5H10M")
     self.assertEqual(dt.timedelta(hours=5, minutes=10), obj.timedelta)
示例#5
0
 def test_weeks(self):
     obj = amazonndt.AmazonDuration("P8W")
     self.assertEqual(dt.timedelta(weeks=8), obj.timedelta)
示例#6
0
 def test_years(self):
     obj = amazonndt.AmazonDuration("P7Y")
     self.assertEqual(dt.timedelta(weeks=52 * 7), obj.timedelta)
示例#7
0
 def test_seconds(self):
     obj = amazonndt.AmazonDuration("PT45S")
     self.assertEqual(dt.timedelta(seconds=45), obj.timedelta)
示例#8
0
 def test_days(self):
     obj = amazonndt.AmazonDuration("P3D")
     self.assertEqual(dt.timedelta(days=3), obj.timedelta)
示例#9
0
 def test_hours(self):
     obj = amazonndt.AmazonDuration("PT5H")
     self.assertEqual(dt.timedelta(hours=5), obj.timedelta)
示例#10
0
 def test_minutes(self):
     obj = amazonndt.AmazonDuration("PT10M")
     self.assertEqual(dt.timedelta(minutes=10), obj.timedelta)
示例#11
0
 def test_raises_on_parse_error(self):
     with self.assertRaises(ValueError):
         obj = amazonndt.AmazonDuration("blah")