#NEWLINE# def test_conditional( ) : #NEWLINE# #INDENT# true_data = bitstring . BitArray ( bytearray ( [ 202 , 232 ] ) ) #NEWLINE# true_data . append ( '0b0' ) #NEWLINE# true_test = b . parse ( true_data , conditional_test ) #NEWLINE# assert_equal ( true_test . qux , True ) #NEWLINE# assert_true ( hasattr ( true_test , 'frooz' ) ) #NEWLINE# assert_false ( hasattr ( true_test , 'fooz' ) ) #NEWLINE# assert_equal ( true_test . frooz , 9 ) #NEWLINE# assert_equal ( true_test . quxz , 93 ) #NEWLINE# assert_equal ( b . write ( true_test , conditional_test ) , bytearray ( [ 202 , 232 , 0 ] ) ) #NEWLINE# false_data = bitstring . BitArray ( bytearray ( [ 72 , 128 ] ) ) #NEWLINE# false_data . append ( '0b1' ) #NEWLINE# false_test = b . parse ( false_data , conditional_test ) #NEWLINE# assert_equal ( false_test . qux , False ) #NEWLINE# assert_true ( hasattr ( false_test , 'fooz' ) ) #NEWLINE# assert_false ( hasattr ( false_test , 'frooz' ) ) #NEWLINE# assert_equal ( false_test . fooz , 145 ) #NEWLINE# assert_equal ( false_test . barz , 1 ) #NEWLINE# assert_equal ( b . write ( false_test , conditional_test ) , bytearray ( [ 72 , 128 , 128 ] ) )