Last active
May 17, 2017 03:44
-
-
Save aipi/99ed2c992be41be437bb9506de73cb44 to your computer and use it in GitHub Desktop.
Django subTest() example code and login test example code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
from __future__ import unicode_literals | |
from django.test import TestCase | |
class (TestCase): | |
def setUp(self): | |
self.superuser = User.objects.create_superuser( | |
email='[email protected]', | |
password='V&ryD@f3Pwd', | |
name='Super User') | |
self.login = self.client.login(email='[email protected]', password='V&ryD@f3Pwd') | |
self.resp = self.client.get('/mouses') | |
def test_login(self): | |
""" Check if is logged """ | |
self.assertTrue(self.login) | |
def test_html(self): | |
""" HTML must contains input tags """ | |
tags = (('<h1>Mouse populations'), | |
('<th>ID'), | |
('<th>Age'), | |
('<th>Skin color'), | |
('<th>Gender'),) | |
for text in tags: | |
with self.subTest(): | |
self.assertContains(self.resp, text) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment