-
-
Save wwj718/7edd44a2df4a9d2192e2 to your computer and use it in GitHub Desktop.
django测试
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 django.test import TestCase, RequestFactory | |
from .models import Blog | |
from django.contrib.auth.models import User | |
class BlogTest(TestCase): | |
def setUp(self): | |
# Every test needs access to the request factory. | |
self.factory = RequestFactory() | |
self.user = User.objects.create_user( | |
username='test', email='test@test.com', password='test') | |
def test_basic_addition(self): | |
""" | |
Tests that 1 + 1 always equals 2. | |
""" | |
#request = self.factory.get('/customer/details') | |
#request.user = self.user | |
#self.assertEqual(1 + 1, 2) | |
self.assertEqual(self.user.username, 'test') | |
#self.assertEqual(1 + 1, 3) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment