<s> from assertpy import assert_that , fail <EOL> class TestDyn ( object ) : <EOL> def setup ( self ) : <EOL> self . fred = Person ( '<STR_LIT>' , '<STR_LIT>' , <NUM_LIT:12> ) <EOL> def test_dynamic_assertion ( self ) : <EOL> assert_that ( self . fred ) . is_type_of ( Person ) <EOL> assert_that ( self . fred ) . is_instance_of ( object ) <EOL> assert_that ( self . fred . first_name ) . is_equal_to ( '<STR_LIT>' ) <EOL> assert_that ( self . fred . last_name ) . is_equal_to ( '<STR_LIT>' ) <EOL> assert_that ( self . fred . shoe_size ) . is_equal_to ( <NUM_LIT:12> ) <EOL> assert_that ( self . fred ) . has_first_name ( '<STR_LIT>' ) <EOL> assert_that ( self . fred ) . has_last_name ( '<STR_LIT>' ) <EOL> assert_that ( self . fred ) . has_shoe_size ( <NUM_LIT:12> ) <EOL> def test_dynamic_assertion_on_property ( self ) : <EOL> assert_that ( self . fred . name ) . is_equal_to ( '<STR_LIT>' ) <EOL> assert_that ( self . fred ) . has_name ( '<STR_LIT>' ) <EOL> def test_dynamic_assertion_on_method ( self ) : <EOL> assert_that ( self . fred . say_hello ( ) ) . is_equal_to ( '<STR_LIT>' ) <EOL> assert_that ( self . fred ) . has_say_hello ( '<STR_LIT>' ) <EOL> def test_dynamic_assertion_failure ( self ) : <EOL> try : <EOL> assert_that ( self . fred ) . has_first_name ( '<STR_LIT>' ) <EOL> fail ( '<STR_LIT>' ) <EOL> except AssertionError as ex : <EOL> assert_that ( str ( ex ) ) . is_equal_to ( '<STR_LIT>' ) <EOL> def test_dynamic_assertion_bad_name_failure ( self ) : <EOL> try : <EOL> assert_that ( self . fred ) . foo ( ) <EOL> fail ( '<STR_LIT>' ) <EOL> except AttributeError as ex : <EOL> assert_that ( str ( ex ) ) . is_equal_to ( "<STR_LIT>" ) <EOL> def test_dynamic_assertion_unknown_attribute_failure ( self ) : <EOL> try : <EOL> assert_that ( self . fred ) . has_foo ( ) <EOL> fail ( '<STR_LIT>' ) <EOL> except AttributeError as ex : <EOL> assert_that ( str ( ex ) ) . is_equal_to ( '<STR_LIT>' ) <EOL> def test_dynamic_assertion_no_args_failure ( self ) : <EOL> try : <EOL> assert_that ( self . fred ) . has_first_name ( ) <EOL> fail ( '<STR_LIT>' ) <EOL> except TypeError as ex : <EOL> assert_that ( str ( ex ) ) . is_equal_to ( '<STR_LIT>' ) <EOL> def test_dynamic_assertion_too_many_args_failure ( self ) : <EOL> try : <EOL> assert_that ( self . fred ) . has_first_name ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> fail ( '<STR_LIT>' ) <EOL> except TypeError as ex : <EOL> assert_that ( str ( ex ) ) . is_equal_to ( '<STR_LIT>' ) <EOL> def test_dynamic_assertion_on_method_failure ( self ) : <EOL> try : <EOL> assert_that ( self . fred ) . has_say_goodbye ( '<STR_LIT>' ) <EOL> fail ( '<STR_LIT>' ) <EOL> except TypeError as ex : <EOL> assert_that ( str ( ex ) ) . contains ( '<STR_LIT>' ) <EOL> def test_chaining ( self ) : <EOL> assert_that ( self . fred ) . has_first_name ( '<STR_LIT>' ) . has_last_name ( '<STR_LIT>' ) . has_shoe_size ( <NUM_LIT:12> ) <EOL> class Person ( object ) : <EOL> def __init__ ( self , first_name , last_name , shoe_size ) : <EOL> self . first_name = first_name <EOL> self . last_name = last_name <EOL> self . shoe_size = shoe_size <EOL> @ property <EOL> def name ( self ) : <EOL> return '<STR_LIT>' % ( self . first_name , self . last_name ) <EOL> def say_hello ( self ) : <EOL> return '<STR_LIT>' % self . first_name <EOL> def say_goodbye ( self , target ) : <EOL> return '<STR_LIT>' % target </s>
