def test_calc_none_bucket(self): with self.assertRaisesRegex(ab.ABTestError, "saw <class 'NoneType'>"): ab.calc(None, buckets=2)
def test_calc_100_buckets(self): self.assertEqual(ab.calc(99, buckets=100), 60)
def test_calc_3_buckets(self): self.assertEqual(ab.calc(99, buckets=3), 1) self.assertEqual(ab.calc(98, buckets=3), 0)
def test_calc_zero_2_buckets(self): self.assertEqual(ab.calc(0, buckets=2), 1)
def test_calc_1_bucket(self): with self.assertRaisesRegex(ab.ABTestError, 'saw 1'): ab.calc(0, buckets=1)
def test_calc_negative_bucket(self): with self.assertRaisesRegex(ab.ABTestError, 'saw -1'): ab.calc(0, buckets=-1)