obspy.core.util.testing.setup_context_testcase

setup_context_testcase(test_case, cm)[source]

Use a contextmanager to set up a unittest test case.

Inspired by Ned Batchelder’s recipe found here: goo.gl/8TBJ7s.

Parameters:
  • test_case An instance of unittest.TestCase
  • cm Any instances which implements the context manager protocol, ie its class definition implements __enter__ and __exit__ methods.