--- D:/apps/Python26/Lib/email/test/test_email-trunk.py Tue Aug 04 01:17:38 2009 +++ D:/apps/Python26/Lib/email/test/test_email.py Tue Aug 04 01:16:46 2009 @@ -2270,6 +2270,29 @@ addrs = Utils.getaddresses(['User ((nested comment)) ']) eq(addrs[0][1], 'foo@bar.com') + def test_utils_make_msgid(self): + """Test make_msgid uniqueness, even with multiple threads""" + NMSGIDS = 10000 + eq = self.assertEqual + try: from threading import Thread + except ImportError: from dummy_threading import Thread + + class MsgidsThread(Thread): + def run(self): + self.msgids = [] + for i in xrange(NMSGIDS): + self.msgids.append(Utils.make_msgid()) + + threads = [MsgidsThread() for i in range(5)] + for t in threads: + t.start() + for t in threads: + t.join() + for t in threads: + eq(len(t.msgids), NMSGIDS) + eq(len(set(t.msgids)), NMSGIDS) + eq(len(set(sum([t.msgids for t in threads], []))), len(threads)*NMSGIDS) + def test_utils_quote_unquote(self): eq = self.assertEqual msg = Message()