Example #1
0
    def testParseUnsupportedUnitRaisesException(self):
        with self.assertRaisesRegexp(ValueError, r".*float.*2us.*"):
            command_parser.parse_readable_time_str("2uss")

        with self.assertRaisesRegexp(ValueError, r".*float.*2m.*"):
            command_parser.parse_readable_time_str("2m")

        with self.assertRaisesRegexp(
                ValueError, r"Invalid time -1. Time value must be positive."):
            command_parser.parse_readable_time_str("-1s")
Example #2
0
  def testParseUnsupportedUnitRaisesException(self):
    with self.assertRaisesRegexp(
        ValueError, r".*float.*2us.*"):
      command_parser.parse_readable_time_str("2uss")

    with self.assertRaisesRegexp(
        ValueError, r".*float.*2m.*"):
      command_parser.parse_readable_time_str("2m")

    with self.assertRaisesRegexp(
        ValueError, r"Invalid time -1. Time value must be positive."):
      command_parser.parse_readable_time_str("-1s")
Example #3
0
 def testParseMillis(self):
   self.assertEqual(2e3, command_parser.parse_readable_time_str("2ms"))
Example #4
0
 def testParseMicros(self):
   self.assertEqual(2, command_parser.parse_readable_time_str("2us"))
Example #5
0
 def testParseSeconds(self):
   self.assertEqual(1e6, command_parser.parse_readable_time_str("1 s"))
   self.assertEqual(2e6, command_parser.parse_readable_time_str("2s"))
Example #6
0
 def testParseNoUnitWorks(self):
   self.assertEqual(0, command_parser.parse_readable_time_str("0"))
   self.assertEqual(100, command_parser.parse_readable_time_str("100 "))
   self.assertEqual(25, command_parser.parse_readable_time_str(" 25 "))
Example #7
0
 def testParseMillis(self):
     self.assertEqual(2e3, command_parser.parse_readable_time_str("2ms"))
Example #8
0
 def testParseMicros(self):
     self.assertEqual(2, command_parser.parse_readable_time_str("2us"))
Example #9
0
 def testParseSeconds(self):
     self.assertEqual(1e6, command_parser.parse_readable_time_str("1 s"))
     self.assertEqual(2e6, command_parser.parse_readable_time_str("2s"))
Example #10
0
 def testParseNoUnitWorks(self):
     self.assertEqual(0, command_parser.parse_readable_time_str("0"))
     self.assertEqual(100, command_parser.parse_readable_time_str("100 "))
     self.assertEqual(25, command_parser.parse_readable_time_str(" 25 "))