'Delete all INBOX.OLITEST* folders on the remote IMAP repository
reponame: All on `reponame` or all IMAP-type repositories if None'

@classmethod
def delete_remote_testfolders(cls, reponame=None):

    config = cls.get_default_config()
    if reponame:
        sections = ['Repository    {0}'.format(reponame)]
    else:
        sections = [r for r in config.sections() if r.startswith('Repository')]
        sections = [s for s in sections if (config.get(s, 'Type').lower() == 'imap')]
    for sec in sections:
        host = config.get(sec, 'remotehost')
        user = config.get(sec, 'remoteuser')
        passwd = config.get(sec, 'remotepass')
        imapobj = imaplib.IMAP4(host)
        imapobj.login(user, passwd)
        (res_t, data) = imapobj.list()
        assert (res_t == 'OK')
        dirs = []
        for d in data:
            if (d == ''):
                continue
            if isinstance(d, tuple):
                folder = ('"%s"' % d[1].replace('"', '\\"'))
            else:
                m = re.search('\n                                                                                                [    ]                                                                                    #    space\n                                                                                                (?P<dir>\n                                                                                                (?P<quote>"?)                                            #    starting    quote\n                                                                                                ([^"]|\\\\")*                                                    #    a    non-quote    or    a    backslashded    quote\n                                                                                                (?P=quote))$                                                #    ending    quote\n                                                                                                ', d, flags=re.VERBOSE)
                folder = bytearray(m.group('dir'))
                if (not m.group('quote')):
                    folder = ('"%s"' % folder)
            dirs.append(folder)
        dirs = [d for d in dirs if (d.startswith('"INBOX.OLItest') or d.startswith('"INBOX/OLItest'))]
        for folder in dirs:
            (res_t, data) = imapobj.delete(folder)
            assert (res_t == 'OK'), 'Folder    deletion    of    {0}    failed    with    error:\n{1}    {2}'.format(folder.decode('utf-8'), res_t, data)
        imapobj.logout()
