gh-7044: set TMPDIR to workingdir in tests

Fix https://github.com/ipython/ipython/issues/7044 and fix the broken test `test_not_writable_ipdir`.