-
Notifications
You must be signed in to change notification settings - Fork 1
/
test.py
34 lines (24 loc) · 839 Bytes
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import glob
import os
from golden_standard import standard_count
OUT_DIR = 'out'
def parse_line(line):
word, count = line.split()
count = int(count)
return word, count
def run_dist_mr():
os.system('python worker.py --name 1 &')
os.system('python worker.py --name 2 &')
os.system('python worker.py --name 3 &')
os.system('python worker.py --name 4 &')
os.system('python driver.py -N 6 -M 4')
def test():
real_counts = standard_count()
run_dist_mr()
for filename in glob.glob(f'{OUT_DIR}/*'):
with open(filename) as file:
for word, count in map(parse_line, file.readlines()):
assert word in real_counts, f'{word} is not in real words'
assert count == real_counts.pop(word)
# the dictionary must be empty
assert not real_counts