1class RunewordsCalculator:
2
3 def __init__(self, runewords):
4 self.runewords = runewords
5 self.met_runes = []
6 self.met_runewords = set()
7
8 def add_runes(self, runes):
9 self.met_runes.extend(runes)
10
11 def __iter__(self):
12 self.num = 0
13 return self
14
15 def __next__(self):
16
17 for key, value in self.runewords.items():
18 if key in self.met_runewords:
19 self.num += 1
20 continue
21
22 curr_rune_index = 0
23 curr_met_rune_index = 0
24 while True:
25 if curr_rune_index == len(value):
26 self.met_runewords.add(key)
27 return key
28
29 if curr_met_rune_index == len(self.met_runes):
30 break
31
32 if value[curr_rune_index] == self.met_runes[curr_met_rune_index]:
33 curr_rune_index += 1
34
35 curr_met_rune_index += 1
36
37 if self.num == len(self.runewords):
38 raise StopIteration
.....F.
======================================================================
FAIL: test_returns_runewords_in_runeword_order (test.TestRunewordsCalculator.test_returns_runewords_in_runeword_order)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/tmp/test.py", line 56, in test_returns_runewords_in_runeword_order
with self.assertRaises(StopIteration):
~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^
AssertionError: StopIteration not raised
----------------------------------------------------------------------
Ran 7 tests in 0.001s
FAILED (failures=1)