def test_raises_error_if_not_int_passed(self): #ARRANGE times = 'a' exc = None #ACT try: nan_expand(times) except Exception as err: exc = err #ASSERT self.assertIsNotNone(exc) self.assertEqual(str(exc), 'Invalid input')
def iterations_on_nan_expand(string): if string.find("Not a NaN") == -1: return False i = 0 while i >= 0: if string == nan_expand(i): return i i += 1
def iterations_of_nan_expand(expanded): new = "Not a " if expanded == "": c = 0 elif new not in expanded: return False elif new in expanded: c = expanded.count(new) return c dif = nan_expand(c) if diff == expanded: return c else: return False
def test_nan_expand(self): self.assertEqual(nan_expand(0), "") self.assertEqual(nan_expand(1), "Not a NaN") self.assertEqual(nan_expand(2), "Not a Not a NaN") self.assertEqual(nan_expand(3), "Not a Not a Not a NaN")
def iterations_of_nan_expand(expanded): times_expanded = (len(expanded) - 3) // 6 nan_expanded = nan_expand(times_expanded) if nan_expanded != expanded: return False return times_expanded
def iterations_of_nan_expand(expanded): times = expanded.count('Not') if nan_expand(times) == expanded: return times return False