'Ensure pytest.raises does not leave a reference cycle (#1965).'

@pytest.mark.parametrize('method', ['function', 'with'])
def test_raises_cyclic_reference(self, method):

    import gc
    class T(object, ):
        def __call__(self):
            raise ValueError
    t = T()
    if (method == 'function'):
        pytest.raises(ValueError, t)
    else:
        with pytest.raises(ValueError):
            t()
    assert (sys.exc_info() == (None, None, None))
    del t
    for o in gc.get_objects():
        assert (type(o) is not T)
