Rewrite lambda as a function.  This avoids a runtime error (i.e. return
value of cached and not cached function differ)  with

SYMPY_USE_CACHE=debug py.test -x sympy/integrals/tests/test_trigonometry.py
Merge pull request #7658 from pbrady/cache_debug_fix

SYMPY_USE_CACHE=debug results in errors