I am currently doing the "Learn Python the Hard Way" of Zed A. Shaw and I am having quite a bit of trouble with exercice 49 using assert_raises. Here is the code that I am using in my test file:
def test_parseVerb():
assert_raises("ParserError",parser.parse_verb,[('stop', 'the'),
('noun', 'bear')])
And this is the error that PowerShell is giving me:
======================================================================
ERROR: tests.parser_tests.test_parseVerb
----------------------------------------------------------------------
Traceback (most recent call last):
File "C:\MrnMicro\Python27\lib\site-packages\nose\case.py", line 197, in runTest
self.test(*self.arg)
File "C:\Documents and Settings\sthma2\Documents\LPTHW\Projects\ex48\tests\parser_tests.py", line 37, in test_parseVer
b
assert_raises("ParserError",parser.parse_verb,fail_list)
File "C:\MrnMicro\Python27\lib\unittest\case.py", line 476, in assertRaises
callableObj(*args, **kwargs)
File "C:\MrnMicro\Python27\lib\unittest\case.py", line 117, in __exit__
if not issubclass(exc_type, self.expected):
TypeError: issubclass() arg 2 must be a class or tuple of classes
----------------------------------------------------------------------
Ran 10 tests in 0.016s
FAILED (errors=1)
I have no idea what is going on to be honest, if someone could help it would be much appreciated !
Thanks !
EDIT
def parse_verb(word_list):
skip(word_list, 'stop')
if peek(word_list) == 'verb':
return match(word_list, 'verb')
else:
raise ParserError("Expected a verb next.")