def test_match_int_succeed_and_exceptions(self): pattern = r"(\d).*" string = r"1, 2, 3" r = _match_int(pattern, string) self.assertIsInstance(r, int) r, e = _match_int(pattern, string, get_exc=True) self.assertIsInstance(r, int) self.assertIsNone(e)
def test_match_int_fail_none_and_exceptions(self): pattern = r"(\d).*" string = r"asdf" r, e = _match_int(pattern, string, get_exc=True) self.assertIsNone(r) self.assertIsInstance(e, Exception)
def test_match_int_fail_none(self): pattern = r"(\d).*" string = r"asdf" r = _match_int(pattern, string) self.assertIsNone(r)
def test_match_int_succeed(self): pattern = r"(\d).*" string = r"1, 2, 3" r = _match_int(pattern, string) self.assertIsInstance(r, int)