When I run this unit test to make it break so it can output a bunch of html 
data.

    self.assertEqual("<h2>Break it!</h2>", *resp.content*)


test.py
# Reset password no login

def test_Reset_no_login(self):
    self.assertTrue(isinstance(self.user, User))
    login = self.client.login(username='captain', password='america')

    self.assertEqual("<h2>Profile</h2>", *resp.content*)

    self.assertNotContains(resp, '<a href="/admin/doc/">Documentation</a>')
    self.assertNotContains(resp, '<a href="/admin/password_change/">Change 
password</a>')
    self.assertNotContains(resp, '<a href="/admin/logout/">Log out</a>')



Then I can't find these html tags in unit test's *resp.content* but when I 
manually check the html source page from the web browser then I see those 3 
html tags.
Why isn't unit test *resp.content* output displaying these 3 html lines?


html source page
http://dpaste.com/0PCZJ0D

<div id="user-tools"> Welcome, <strong>joe</strong>. 


*<a href="/admin/doc/">Documentation</a> / <a 
href="/admin/password_change/">Change password</a> / <a 
href="/admin/logout/">Log out</a> *
</div>


unit test output
http://dpaste.com/23XGR4M.txt

======================================================================
FAIL: test_Reset_no_login (userprofile.tests.PasswordResetTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/Python/Projects/Navi/Django/navi/userprofile/tests.py", line 
132, in test_Reset_no_login

    self.assertEqual("<h2>Profile</h2>", resp.content)

AssertionError: '<h2>Profile</h2>' != '<!DOCTYPE html>\n<html lang="en-us" 
>\n<head>\n<title>Password reset - v.2</title>\n<link rel="stylesheet" 
type="text/css" href="/static/admin/css/base.css" />\n\n<!--[if lte IE 
7]><link rel="stylesheet" type="text/css" href="/static/admin/css/ie.css" 
/><![endif]-->\n\n<script 
type="text/javascript">window.__admin_media_prefix__ = 
"/static/admin/";</script>\n\n<meta name="robots" content="NONE,NOARCHIVE" 
/>\n</head>\n\n\n<body class="">\n\n<!-- Container -->\n<div 
id="container">\n\n    \n    <!-- Header -->\n    <div 
id="header">\n        <div id="branding">\n        \n<h1 
id="site-name">Navi administration - v.1</h1>\n\n        </div>\n        
\n        <p>Admin navigation</p>\n    </div>\n    <!-- END Header -->\n    
\n    <div class="breadcrumbs">\n    <a href="/admin/">Home</a>\n    \n    
</div>\n    \n    \n\n    \n        \n    \n\n    <!-- Content -->\n    
<div id="content" class="colM">\n        \n        \n        \n<h1>Password 
reset</h1>\n<p>Forgotten your password? Enter your email address below, and 
we\'ll email instructions for setting a new one.</p>\n\n<form action="" 
method="post"><input type=\'hidden\' name=\'csrfmiddlewaretoken\' 
value=\'iXJku3wGmCRg95SlHqC5QfHEH48XCRRZ\' />\n\n<p><label 
for="id_email">Email address:</label> <input id="id_email" maxlength="254" 
name="email" type="text" /> <input type="submit" value="Reset my password" 
/></p>\n</form>\n\n        \n        <br class="clear" />\n    </div>\n    
<!-- END Content -->\n\n    <div id="footer"></div>\n</div>\n<!-- END 
Container -->\n\n</body>\n</html>\n'

----------------------------------------------------------------------
Ran 36 tests in 5.981s

FAILED (failures=1)
Destroying test database for alias 'default' (':memory:')...


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/c20a58c5-fad3-4ba6-906e-ca99158f9db6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to