Exemplo n.º 1
0
 def desc_should_use_comparator(self):
     ''' describe_constraint should delegate to comparator.description ''' 
     comparator = MockSpec()
     spec = Spec(Constraint(comparator))
     comparator_description = comparator.description()
     comparator_description.will_return('subtitled')
     spec.describe_constraint()
     spec.should_collaborate_with(comparator_description,
                                  and_result='should be subtitled')
Exemplo n.º 2
0
 def desc_should_use_comparator(self):
     ''' describe_constraint should delegate to comparator.description '''
     comparator = MockSpec()
     spec = Spec(Constraint(comparator))
     comparator_description = comparator.description()
     comparator_description.will_return('subtitled')
     spec.describe_constraint()
     spec.should_collaborate_with(comparator_description,
                                  and_result='should be subtitled')
Exemplo n.º 3
0
def notification_behaviour():
    ''' listener should receive notifications AllVerifiable.verify() '''
    listener = MockSpec()
    all_verifiable_with_mock_listener = AllVerifiable(listener)
    results = {'total': 3, 'verified': 1, 'unverified': 2}

    spec = Spec(all_verifiable_with_mock_listener)
    spec.when(spec.include(string_abc), spec.include(raise_index_error),
              spec.include(unmet_specification))
    spec.then(spec.verify())
    spec.should_collaborate_with(
        listener.all_verifiable_starting(all_verifiable_with_mock_listener),
        listener.verification_started(string_abc),
        listener.specification_met(string_abc),
        listener.verification_started(raise_index_error),
        listener.unexpected_exception(raise_index_error, Type(IndexError)),
        listener.verification_started(unmet_specification),
        listener.specification_unmet(unmet_specification,
                                     Type(UnmetSpecification)),
        listener.all_verifiable_ending(all_verifiable_with_mock_listener,
                                       results),
        and_result=results)
Exemplo n.º 4
0
def notification_behaviour(): 
    ''' listener should receive notifications AllVerifiable.verify() '''
    listener = MockSpec()
    all_verifiable_with_mock_listener = AllVerifiable(listener)
    results = {'total': 3, 'verified': 1, 'unverified': 2}
    
    spec = Spec(all_verifiable_with_mock_listener)
    spec.when(spec.include(string_abc), 
              spec.include(raise_index_error),
              spec.include(unmet_specification)) 
    spec.then(spec.verify())
    spec.should_collaborate_with(
        listener.all_verifiable_starting(all_verifiable_with_mock_listener),
        listener.verification_started(string_abc),
        listener.specification_met(string_abc),
        listener.verification_started(raise_index_error),
        listener.unexpected_exception(raise_index_error, Type(IndexError)),
        listener.verification_started(unmet_specification),
        listener.specification_unmet(unmet_specification, 
                                     Type(UnmetSpecification)),
        listener.all_verifiable_ending(all_verifiable_with_mock_listener, 
                                       results),
        and_result = results)