Note that there are some explanatory texts on larger screens.

plurals
  1. PODjango-nose test case gives assertion error when run from management command
    primarykey
    data
    text
    <p>test.py </p> <pre><code># write code to test the views. from django.test import Client # import nose for tests. import nose.tools as noz class TestSettings(object): """ test the nose test related setup """ def setup(self): self.client = Client() def testTestUser(self): """ Tests if the django user 'test' is setup properly.""" # login the test user response = self.client.login(username=u'test', password=u'test') noz.assert_equal(response, True) </code></pre> <p>when this code is run from management command, gives the following output : </p> <pre><code> $ ./manage.py test &lt;app-name&gt; nosetests --verbosity 1 &lt;app-name&gt; Creating test database for alias 'default'... F ====================================================================== FAIL: Tests if the django user 'test' is setup properly. ---------------------------------------------------------------------- Traceback (most recent call last): File "/&lt;python-sitepackages-dir-path&gt;/nose/case.py", line 197, in runTest self.test(*self.arg) File "&lt;application-path&gt;/tests.py", line 28, in testTestUser noz.assert_equal(response, True) AssertionError: False != True ---------------------------------------------------------------------- Ran 1 test in 0.008s FAILED (failures=1) Destroying test database for alias 'default'... </code></pre> <p>now the same commands when run thrugh the django shell gives the following:</p> <pre><code> $ ./manage.py shell Python 2.6.6 (r266:84292, Sep 11 2012, 08:28:27) [GCC 4.4.6 20120305 (Red Hat 4.4.6-4)] on linux2 Type "help", "copyright", "credits" or "license" for more information. (InteractiveConsole) &gt;&gt;&gt; from django.test import Client &gt;&gt;&gt; &gt;&gt;&gt; import nose.tools as noz &gt;&gt;&gt; &gt;&gt;&gt; client = Client() &gt;&gt;&gt; response = client.login(username=u'test', password=u'test') &gt;&gt;&gt; noz.assert_equal(response, True) &gt;&gt;&gt; &gt;&gt;&gt; &gt;&gt;&gt; response True &gt;&gt;&gt; </code></pre> <p>The user 'test' is active in django for the current scenrio.</p> <p>Why am i getting this error assertion while i run the management command ?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload