LPTHW:Ex48 Unit test(using nosetests), Classes,method arguments TypeErrors
<p>Hello I am Newbie working through LPTHW <a href="http://learnpythonthehardway.org/book/ex48.html" rel="nofollow">This is the link for it</a>.At ex48 I am given a lot of code as unit tests to wich I am supposed to write the corresponding my_code wich will be tested(using nosetests, sry lots of tests in this sentence.)</p>

<p>this is my_code:     </p>

<pre><code>class lexicon(object):

    def __init__(self):
    #some initial stuff.

    def scan(self,stuff):
    #some cool code.
</code></pre>

<p>And this is the test.py file</p>

<pre><code>from nose.tools import*
from Ex48.code import lexicon

def test_directions():    

    assert_equal(lexicon.scan("north"), [('direction', 'north')])
    ...#Unimportant details the above is enough.
</code></pre>

<p>However when I run nosetests I get the following error: </p>

<pre><code>Traceback (most recent call last):
    File "c:\python31\lib\site-packages\nose'case.py", line 197, i runTest
    ... line x, in test_directions
    assert_equal(lexicon.scan("north"), [('direction', 'north')])
TypeError: scan() takes exactly 2 positional arguments (1 given)
</code></pre>

<p>Wich is odd because one of those 2 arguments is the self one and I thought it should not be given.</p>

<p>To remedy this problem I have tried:</p>

<pre><code>@staticmethod
def scan(self,stuff):
</code></pre>

<p>But this gave me the same typeError</p>

<p>Next I tried:</p>

<pre><code>assert_equal(lexicon.__init__(self).scan(...)
</code></pre>

<p>But this didn't work either(I think .<strong>_<em>init</em>_</strong>(self) should be used in another class than lexicon only, not in main).</p>

<p>I Finally resolved to:</p>

<pre><code>lexicon1=lexicon()
def test_directions():    
    assert_equal(lexicon1.scan("north"), [('direction', 'north')])
</code></pre>

<p>But this is not how the exercise is supposed to be done!
Please help!Sry about the long post!</p>

<p>P.S:I did not include the whole traceback bc it might not be necessary(and it's getting very late).If anybody thinks otherwise plz comment so I'll add it.
I did not include parts of my code bc I'm sure that it works fine and is not causing the error!  </p>
