Permalink
Browse files

bugfix: test_reqmodules checked results incorrectly

  • Loading branch information...
1 parent 51d27f5 commit 0c7cacf2af61a5dc23d4e642928bd168795f50a5 Ville Tuulos committed Oct 24, 2008
Showing with 13 additions and 6 deletions.
  1. +13 −6 test/test_reqmodules.py
View
@@ -6,7 +6,8 @@ def data_gen(path):
return path[1:] + "\n"
def fun_map(e, params):
- return [(md5.new(str(math.pow(int(e), 2))).digest(), "")]
+ k = str(int(math.ceil(float(e))) ** 2)
+ return [(md5.new(k).hexdigest(), "")]
tserver.run_server(data_gen)
disco = Disco(sys.argv[1])
@@ -19,11 +20,17 @@ def fun_map(e, params):
required_modules = ["math", "md5"],
sort = False)
-for i, r in zip(inputs, result_iterator(job.wait())):
- c = md5.new(str(math.pow(int(i), 2))).digest()
- if c != r[0]:
- raise Exception("Invalid answer: Correct: %s Got: %s"\
- % (c, r[0]))
+res = list(result_iterator(job.wait()))
+if len(res) != len(inputs):
+ raise Exception("Too few results: Got: %d Should be %d" %
+ (len(res), len(inputs)))
+
+cor = map(lambda x: md5.new(str(int(math.ceil(x)) ** 2)).hexdigest(), inputs)
+
+for k, v in res:
+ if k not in cor:
+ raise Exception("Invalid answer: %s" % k)
+ cor.remove(k)
job.clean()
print "ok"

0 comments on commit 0c7cacf

Please sign in to comment.