import itertools
import traceback


class MockDateTime(object):
    def __init__(self, ret):
        try:
            self.ret = iter(ret)
        except TypeError:
            self.ret = iter(itertools.repeat(ret))

    def utcnow(self):
        return next(self.ret)

class MockDateTime(object):
    def __init__(self, ret):
        try:
            self.ret = iter(ret)
        except TypeError:
            self.ret = iter((ret,))

    def utcnow(self):
        try:
            return next(self.ret)
        except StopIteration:
            raise ValueError('No more mock values!')

Raise error in mock if there are not enough mock datetime values
Raise error in mock if there are not enough mock datetime values

- import itertools
- import traceback
- 
- 
  class MockDateTime(object):
      def __init__(self, ret):
          try:
              self.ret = iter(ret)
          except TypeError:
-             self.ret = iter(itertools.repeat(ret))
+             self.ret = iter((ret,))
  
      def utcnow(self):
+         try:
-         return next(self.ret)
+             return next(self.ret)
+         except StopIteration:
+             raise ValueError('No more mock values!')
  
Raise error in mock if there are not enough mock datetime values
## Code Before:
import itertools
import traceback


class MockDateTime(object):
    def __init__(self, ret):
        try:
            self.ret = iter(ret)
        except TypeError:
            self.ret = iter(itertools.repeat(ret))

    def utcnow(self):
        return next(self.ret)

## Instruction:
Raise error in mock if there are not enough mock datetime values
## Code After:
class MockDateTime(object):
    def __init__(self, ret):
        try:
            self.ret = iter(ret)
        except TypeError:
            self.ret = iter((ret,))

    def utcnow(self):
        try:
            return next(self.ret)
        except StopIteration:
            raise ValueError('No more mock values!')
