Hi,
I am getting the below error and I am stuck in this. Could you please guide me how to fix this?
sam@sam-Inspiron-5720:~/mine/allprojects/ex48/skeleton$ nosetests
E
======================================================================
ERROR: tests.lexicon_tests.test_directions
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/local/lib/python**3.5/**dist-packages/nose/case.py", line 198, in runTest
self.test(*self.arg)
File "/home/sam/mine/allprojects/ex48/skeleton/tests/lexicon_tests.py", line 6, in test_directions
assert_equal(lexicon.scan("north"), [('direction', 'north')])
UnboundLocalError: local variable 'assert_equal' referenced before assignment
----------------------------------------------------------------------
Ran 1 test in 0.004s
FAILED (errors=1)
sam@sam-Inspiron-5720:~/mine/allprojects/ex48/skeleton$
I have the same lexicon.py code of yours too and ran it. Still I am getting the same error.
Also, the distribute is pointed to python3.5. I tried to update it for python3.6.
Below is my lexicon.py code for the tests.
lexicon = {
"north": 'direction',
"south": 'direction',
"east": 'direction'
}
def scan(sentence):
results = []
words = sentence.split()
for word in words:
word_type = lexicon.get(word)
results.append((word_type, word))
return results
Note: If i run the first test line " assert_equal(lexicon.scan(“north”), [(‘direction’, ‘north’)])" alone, it works fine.
The error appears when I try to run the full block as below.
def test_directions():
**assert_equal(lexicon.scan("north"), [('direction', 'north')])**
result = lexicon.scan("north south east")
assert_equal = (result, [('direction', 'north'),
('direction', 'south'),
('direction', 'east')])
Please guide me to fix this, Thank you very much!