'Check that a cycle in alias resolution is correctly handled.'

def test_cyclicAlias(self):

    aliases = {}
    domain = {'': TestDomain(aliases, [])}
    A1 = mail.alias.AddressAlias('alias2', domain, 'alias1')
    A2 = mail.alias.AddressAlias('alias3', domain, 'alias2')
    A3 = mail.alias.AddressAlias('alias1', domain, 'alias3')
    aliases.update({'alias1': A1, 'alias2': A2, 'alias3': A3})
    self.assertEqual(aliases['alias1'].resolve(aliases), None)
    self.assertEqual(aliases['alias2'].resolve(aliases), None)
    self.assertEqual(aliases['alias3'].resolve(aliases), None)
    A4 = MockAliasGroup(['|echo', 'alias1'], domain, 'alias4')
    aliases['alias4'] = A4
    res = A4.resolve(aliases)
    r = map(str, res.objs)
    r.sort()
    expected = map(str, [mail.alias.MessageWrapper(DummyProcess(), 'echo')])
    expected.sort()
    self.assertEqual(r, expected)
