Fix #8886. Use context managers throughout the test.
2 files changed