def execute_count(expected):
 def innerCounter(fn):
  def wrapped_function(*args, **kwargs):
   count = StatementCounter(cassandra.cqlengine.connection.execute)
   original_function = cassandra.cqlengine.connection.execute
   cassandra.cqlengine.connection.execute = count.wrapped_execute
   to_return = fn(*args, **kwargs)
   count.get_counter()
   cassandra.cqlengine.connection.execute = original_function
   if (len(args) is 0):
    test_case = unittest.TestCase('__init__')
   else:
    test_case = args[0]
   test_case.assertEqual(count.get_counter(), expected, msg="Expected number of cassandra.cqlengine.connection.execute calls ({0}) doesn't match actual number invoked ({1})".format(expected, count.get_counter()))
   return to_return
  wrapped_function.__name__ = fn.__name__
  wrapped_function.__doc__ = fn.__doc__
  if CQL_SKIP_EXECUTE:
   return fn
  else:
   return wrapped_function
 return innerCounter

def execute_count ( expected ) : def innerCounter ( fn ) : def wrapped_function ( * args , ** kwargs ) : count = StatementCounter ( cassandra . cqlengine . connection . execute ) original_function = cassandra . cqlengine . connection . execute cassandra . cqlengine . connection . execute = count . wrapped_execute to_return = fn ( * args , ** kwargs ) count . get_counter ( ) cassandra . cqlengine . connection . execute = original_function if ( len ( args ) is 0 ) : test_case = unittest . TestCase ( '__init__' ) else : test_case = args [ 0 ] test_case . assertEqual ( count . get_counter ( ) , expected , msg = "Expected number of cassandra.cqlengine.connection.execute calls ({0}) doesn't match actual number invoked ({1})" . format ( expected , count . get_counter ( ) ) ) return to_return wrapped_function . __name__ = fn . __name__ wrapped_function . __doc__ = fn . __doc__ if CQL_SKIP_EXECUTE : return fn else : return wrapped_function return innerCounter
a decorator used wrap cassandra .