Example #1
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) 
    
@verifiable
def should_contain_behaviour():
    ''' should_ and should_not_ contain methods delegate to Contain '''
    spec = Spec(['brave', 'brave', 'sir robin'])
    spec.it().should_contain('brave')
    spec.it().should_not_contain('bravely ran away')
    
@verifiable
def should_raise_optional_args():
    ''' should_raise and should_not_raise should not require args, and if
    no args are specified then the catch-all value of Exception is assumed '''
    Spec(raise_index_error).raise_index_error().should_raise()
    Spec(dont_raise_index_error).dont_raise_index_error().should_not_raise()
    
if __name__ == '__main__':
    verify()
Example #2
0
'''
BDD-style Lancelot specifications for the behaviour of the core library classes
'''
from waferslim.fixtures import EchoFixture

import lancelot

class EchoFixtureBehaviour(object):
    @lancelot.verifiable
    def echo_should_return_str_passed_in(self):
        echoer = lancelot.Spec(EchoFixture())
        echoer.echo('hello world').should_be('hello world')
        echoer.echo('1').should_be('1')

lancelot.grouping(EchoFixtureBehaviour)

if __name__ == '__main__':
    lancelot.verify()
Example #3
0
'''
BDD-style Lancelot specifications for the behaviour of the core library classes
Lancelot is distributed at http://pypi.python.org/pypi/lancelot
and the latest source is available at https://launchpad.net/lancelot.
'''

import lancelot

if __name__ == '__main__':
    from waferslim.specs import protocol_spec, instruction_spec, \
                                execution_spec, converter_spec, \
                                fixtures_spec, integration
    lancelot.verify(fail_fast=False)
Example #4
0
'''
Sub-package with some example Specs to illustrate usage scenarios 
'''

import lancelot

if __name__ == '__main__':
    # Verify all the specs as a collection
    from lancelot.examples import fibonacci_spec, stack_spec, \
        observer_spec, additional_comparators
    lancelot.verify()
Example #5
0
    spec.description().should_be("=> 2")
    spec.compares_to(2).should_be(True)
    spec.compares_to(1).should_be(False)
    spec.compares_to('a').should_be(False)


@verifiable
def anything_behaviour():
    ''' Anything comparator should find all compared objects equivalent. '''
    spec = Spec(Anything())
    spec.description().should_be("anything")
    spec.compares_to(1).should_be(True)
    spec.compares_to('1').should_be(True)
    spec.compares_to([1]).should_be(True)
    spec.compares_to('xyz').should_be(True)


@verifiable
def nothing_behaviour():
    ''' Nothing comparator should never find compared objects equivalent. '''
    spec = Spec(Nothing())
    spec.description().should_be("nothing")
    spec.compares_to(1).should_be(False)
    spec.compares_to('1').should_be(False)
    spec.compares_to([1]).should_be(False)
    spec.compares_to('xyz').should_be(False)


if __name__ == '__main__':
    verify()