'Test cleanup on StopIteration'

def test_nrt_gen0_stop_iteration(self):

    pygen = nrt_gen0
    cgen = jit(nopython=True)(pygen)
    py_ary = np.arange(1)
    c_ary = py_ary.copy()
    py_iter = pygen(py_ary)
    c_iter = cgen(c_ary)
    py_res = next(py_iter)
    c_res = next(c_iter)
    with self.assertRaises(StopIteration):
        py_res = next(py_iter)
    with self.assertRaises(StopIteration):
        c_res = next(c_iter)
    del py_iter
    del c_iter
    np.testing.assert_equal(py_ary, c_ary)
    self.assertEqual(py_res, c_res)
    self.assertEqual(sys.getrefcount(py_ary), sys.getrefcount(c_ary))
