'This function is not itself a test; rather, it can be used by any test
that has created placeholders. It will check that whatever the plugin
structure in the placeholder, it will be copied accurately when they are
copied.
placeholders is a list of placeholders'

def copy_placeholders_and_check_results(self, placeholders):

    for original_placeholder in placeholders:
        original_plugins = original_placeholder.get_plugins()
        copied_placeholder = Placeholder.objects.create(slot=original_placeholder.slot)
        copy_plugins_to(original_placeholder.get_plugins(), copied_placeholder)
        copied_plugins = copied_placeholder.get_plugins()
        self.assertEqual(original_plugins.count(), copied_plugins.count())
        for (original, copy) in zip(original_plugins, copied_plugins):
            self.assertEqual(Text.objects.get(id=original.id).body, Text.objects.get(id=copy.id).body)
        original_plugins_list = []
        copied_plugins_list = []
        def plugin_list_from_tree(roots, plugin_list):
            for plugin in roots:
                plugin_list.append(plugin)
                plugin_list_from_tree(plugin.get_children(), plugin_list)
        plugin_list_from_tree(original_plugins.filter(depth=1), original_plugins_list)
        plugin_list_from_tree(copied_plugins.filter(depth=1), copied_plugins_list)
        self.assertEqual(len(original_plugins_list), original_plugins.count())
        self.assertEqual(len(copied_plugins_list), copied_plugins.count())
        for (original, copy) in zip(original_plugins_list, copied_plugins_list):
            original_text_plugin = Text.objects.get(id=original.id)
            copied_text_plugin = Text.objects.get(id=copy.id)
            self.assertNotEquals(original.id, copy.id)
            self.assertEqual(original_text_plugin.body, copied_text_plugin.body)
            self.assertEqual(original_text_plugin.depth, copied_text_plugin.depth)
            self.assertEqual(original_text_plugin.position, copied_text_plugin.position)
            self.assertEqual(original_text_plugin.numchild, copied_text_plugin.numchild)
            self.assertEqual(original_text_plugin.get_descendant_count(), copied_text_plugin.get_descendant_count())
            self.assertEqual(original_text_plugin.get_ancestors().count(), copied_text_plugin.get_ancestors().count())
    return copied_placeholder
