def test_from_float(self): cases = [(float(100), None, TimeValue(Timestamp.from_str("100:0"))), (float(100), Fraction(25), TimeValue.from_str("2500@25")), (float(4), None, TimeValue(100, rate=Fraction(25))), (float(2.5), Fraction(50), TimeValue.from_str("125@50")), (float(7.6), None, TimeValue(TimeOffset.from_str("7:600000000"))), (float(3.6), Fraction(100), TimeValue(TimeOffset.from_str("3:600000000"), rate=Fraction(100)))] for case in cases: with self.subTest(case=case): self.assertEqual(TimeValue.from_float(case[0], rate=case[1]), case[2])
def test_hashable(self): tv1 = TimeValue(0) tv2 = TimeValue.from_str("0:20000000000@50") self.assertNotEqual(hash(tv1), hash(tv2))
def test_from_str_rate(self): tv = TimeValue.from_str("100@25", rate=Fraction(100)) self.assertEqual(tv, TimeValue(100, rate=Fraction(25))) tv = TimeValue.from_str("100", rate=Fraction(100)) self.assertEqual(tv, TimeValue(100, rate=Fraction(100)))