'A contextmanager that returns an isolated versioning modulestore, and then deletes
all of its data at the end of the context.
Args:
contentstore: The contentstore that this modulestore should use to store
all of its assets.'

@contextmanager
def build_with_contentstore(self, contentstore, **kwargs):

    doc_store_config = dict(db='modulestore{}'.format(random.randint(0, 10000)), collection='split_module', **COMMON_DOCSTORE_CONFIG)
    fs_root = mkdtemp()
    modulestore = DraftVersioningModuleStore(contentstore, doc_store_config, fs_root, render_template=repr, xblock_mixins=XBLOCK_MIXINS, **kwargs)
    modulestore.ensure_indexes()
    try:
        (yield modulestore)
    finally:
        modulestore._drop_database()
        rmtree(fs_root, ignore_errors=True)
