I’m having trouble with the match function. When I test it with assert_equal(), it only passes when I return the entire word_list. I thought the match function was supposed to only return the first word in the word_list?
Test below, can you help me understand what I’m missing?
Test:
from nose.tools import *
from ex49 import parser
def test_user_string():
assert_raises(TypeError, parser.Sentence('bear', 'go', 'south'), )
def test_peek():
assert_equal(parser.peek([('bear', 'go')]), 'bear')
def test_match():
assert_equal(parser.match([('bear', 'go')], 'go'), None)
assert_equal(parser.match([('bear', 'go')], 'bear'), 'bear')
Result:
FAIL: parser_tests.test_match
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Users/sean_mc/mystuff/projects/env/lib/python3.6/site-packages/nose/case.py", line 198, in runTest
self.test(*self.arg)
File "/Users/sean_mc/mystuff/projects/ex49/tests/parser_tests.py", line 12, in test_match
assert_equal(parser.match([('bear', 'go')], 'bear'), 'bear')
AssertionError: ('bear', 'go') != 'bear'
----------------------------------------------------------------------
Ran 3 tests in 0.010s
FAILED (failures=1)