예제 #1
0
def given_when_then_behaviour(): 
    ''' given empty list when item appended then list length should be one '''
    spec = Spec([])
    spec.when(spec.append(object())).then(spec.it()).should_be(Length(1))

    def empty_list():
        ''' descriptive name for fn returning an empty list '''
        return []
    spec = Spec(type([]), given=empty_list)
    spec.when(spec.append('monty')).then(spec.it()).should_be(Length(1))
예제 #2
0
def given_when_then_behaviour():
    ''' given empty list when item appended then list length should be one '''
    spec = Spec([])
    spec.when(spec.append(object())).then(spec.it()).should_be(Length(1))

    def empty_list():
        ''' descriptive name for fn returning an empty list '''
        return []

    spec = Spec(type([]), given=empty_list)
    spec.when(spec.append('monty')).then(spec.it()).should_be(Length(1))
예제 #3
0
def external_then_behaviour(): 
    ''' Spec for then()... actions that call outside the spec itself.
    
    Note that the action on the spec is invoked in client code with parens():
        spec.then( * spec.__len__() * ).should_be(1)
        
    but the action outside the spec is NOT:
        spec.then( * 'they called him brian'.__len__ * ).should_be(21) 
    '''
    spec = Spec([])
    spec.when(spec.append('brian'))
    spec.then(spec.__len__()).should_be(1)
    spec.then('they called him brian'.__len__).should_be(21) 
예제 #4
0
def external_then_behaviour():
    ''' Spec for then()... actions that call outside the spec itself.
    
    Note that the action on the spec is invoked in client code with parens():
        spec.then( * spec.__len__() * ).should_be(1)
        
    but the action outside the spec is NOT:
        spec.then( * 'they called him brian'.__len__ * ).should_be(21) 
    '''
    spec = Spec([])
    spec.when(spec.append('brian'))
    spec.then(spec.__len__()).should_be(1)
    spec.then('they called him brian'.__len__).should_be(21)