|
@@ -157,6 +157,30 @@ class MyTestCase(unittest.TestCase):
|
|
|
consumer.quit()
|
|
|
consumer.join()
|
|
|
|
|
|
+ def test_merge(self):
|
|
|
+ from collections import defaultdict
|
|
|
+ import time as time
|
|
|
+
|
|
|
+ def merge(l,r):
|
|
|
+ for name,ls in l.items():
|
|
|
+ if name in r:
|
|
|
+ ls.extend(r[name])
|
|
|
+ k = set(ls)
|
|
|
+ r[name] = list(k)
|
|
|
+ else:
|
|
|
+ r[name] = ls
|
|
|
+ return r
|
|
|
+
|
|
|
+ all = defaultdict(list)
|
|
|
+ a = {'yunchonggongfs': [(4, 100), (4, 30), (4, 50)]}
|
|
|
+ b = {'yunchonggongfs': [(4, 100), (4, 200), (4, 50)]}
|
|
|
+
|
|
|
+ all = merge(a,all)
|
|
|
+ all = merge(b,all)
|
|
|
+ x = 0;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
unittest.main()
|