@contextlib.contextmanager
def ctx_assert_warnings(self):
    with warnings.catch_warnings(record=True) as w:
        # Raise all warnings
        warnings.simplefilter('always')

        # Return to caller
        yield

        # Assert that a warning was raised.
        self.assertTrue(len(w) > 0)
Context manager for verifying that a block of code has raised a
dataset/ETHPy150Open STIXProject/python-stix/stix/test/__init__.py/ctx_assert_warnings