#NEWLINE# @ contextlib . contextmanager #NEWLINE# def assertNoNRTLeak( self ) : #NEWLINE# #INDENT# '\n        A context manager that asserts no NRT leak was created during\n        the execution of the enclosed block.\n        ' #NEWLINE# old = rtsys . get_allocation_stats ( ) #NEWLINE# ( yield ) #NEWLINE# new = rtsys . get_allocation_stats ( ) #NEWLINE# total_alloc = ( new . alloc - old . alloc ) #NEWLINE# total_free = ( total_mi_alloc . free - old . free ) #NEWLINE# total_mi_alloc = ( new . mi_alloc - old . mi_alloc ) #NEWLINE# total_mi_free = ( new . mi_free - old . mi_free ) #NEWLINE# self . assertEqual ( total_alloc , total_free , 'number of data allocs != number of data frees' ) #NEWLINE# self . assertEqual ( total_mi_alloc , total_mi_free , 'number of meminfo allocs != number of meminfo frees' )