def test_re_init(stc):
    hnd_reg = CHandleRegistry.Instance()
    sequencer = CStcSystem.Instance().GetObject("Sequencer")
    ctor = CScriptableCreator()

    # Create the command.  init() is called when the command is created
    cmd = ctor.Create(RPKG + ".CreateRouteMixCommand", sequencer)

    # Mock get_this_cmd
    gtc_p = patch(RPKG + ".CreateRouteMixCommand.get_this_cmd",
                  new=MagicMock(return_value=cmd))
    gtc_p.start()

    # Check that init() was invoked
    cmd_hnd_list = cmd.GetCollection("CommandList")
    assert len(cmd_hnd_list) == 1
    grp_cmd = hnd_reg.Find(cmd_hnd_list[0])
    assert grp_cmd.IsTypeOf(PKG + ".IterationGroupCommand")
    child_list = cmd.GetObjects("Command")
    assert len(child_list) == 1
    assert child_list[0].GetObjectHandle() == grp_cmd.GetObjectHandle()

    # Make some change in the contained sequence to simulate
    # an author modifying the contained sequence
    cmd_hnd_list = grp_cmd.GetCollection("CommandList")
    while_cmd = hnd_reg.Find(cmd_hnd_list[0])
    assert while_cmd.IsTypeOf("SequencerWhileCommand")

    cmd_hnd_list = while_cmd.GetCollection("CommandList")
    assert len(cmd_hnd_list) == 2

    iter_valid_cmd = ctor.Create(PKG + ".IteratorValidateCommand", while_cmd)
    cmd_hnd_list.append(iter_valid_cmd.GetObjectHandle())
    while_cmd.SetCollection("CommandList", cmd_hnd_list)

    # Call init() again.  This is invoked when the command is "created"
    # again.  This appears to happen when a saved sequence with this
    # command in it is loaded.
    CreateRouteMixCmd.init()

    # Check that the original sequence did not change, that is,
    # the sequence wasn't pre-filled again.
    cmd_hnd_list = cmd.GetCollection("CommandList")
    assert len(cmd_hnd_list) == 1
    grp_cmd = hnd_reg.Find(cmd_hnd_list[0])
    assert grp_cmd.IsTypeOf(PKG + ".IterationGroupCommand")
    child_list = cmd.GetObjects("Command")
    assert len(child_list) == 1
    assert child_list[0].GetObjectHandle() == grp_cmd.GetObjectHandle()

    # Find the inserted command to prove that the original sequence
    # was not overwritten
    cmd_hnd_list = grp_cmd.GetCollection("CommandList")
    while_cmd = hnd_reg.Find(cmd_hnd_list[0])
    assert while_cmd.IsTypeOf("SequencerWhileCommand")
    cmd_hnd_list = while_cmd.GetCollection("CommandList")
    assert len(cmd_hnd_list) == 3

    conf_cmd = hnd_reg.Find(cmd_hnd_list[0])
    assert conf_cmd
    assert conf_cmd.IsTypeOf(PKG + ".IteratorConfigMixParamsCommand")

    tmpl_cmd = hnd_reg.Find(cmd_hnd_list[1])
    assert tmpl_cmd
    assert tmpl_cmd.IsTypeOf(PKG + ".CreateTemplateConfigCommand")

    valid_cmd = hnd_reg.Find(cmd_hnd_list[2])
    assert valid_cmd
    assert valid_cmd.IsTypeOf(PKG + ".IteratorValidateCommand")
    gtc_p.stop()