def setUp(self):
    'Setup test fixure\n\n        The constructor of CommonTokenStream needs a token source. This\n        is a simple mock class providing just the nextToken() method.\n\n        '

    class MockSource(object):

        def __init__(self):
            self.tokens = []

        def nextToken(self):
            try:
                return self.tokens.pop(0)
            except IndexError:
                return None
    self.source = MockSource()
Setup test fixure

The constructor of CommonTokenStream needs a token source. This
is a simple mock class providing just the nextToken() method.
def setUp(self):
    'Setup test fixure\n\n        The constructor of CommonTokenStream needs a token source. This\n        is a simple mock class providing just the nextToken() method.\n\n        '

    class MockSource(object):

        def __init__(self):
            self.tokens = []

        def nextToken(self):
            try:
                return self.tokens.pop(0)
            except IndexError:
                return None
    self.source = MockSource()