首页 新闻 会员 周边

python下搭建的django项目,跑单元测试文件时,突然给我报错Apps aren't loaded yet.,项目网站还能够正常运行,我表示好懵逼啊,求大神帮我看看啊

0
[待解决问题]

不知道怎么回事,之前全部都是能够正常运行的。

代码如下:

from django.test import TestCase
from django.contrib.auth.models import User
from sign.models import Event, Guest

# Create your tests here.
class IndexPageTest(TestCase):
    ''' 测试index登录首页 '''

    def test_index_page_renders_index_template(self):
        '''测试index视图'''
        response = self.client.get('/index/')
        self.assertEqual(response.status_code,200)
        self.assertTemplateUsed(response,'index.html')

class LoginActionTest(TestCase):
    '''测试登录动作'''

    def setUp(self):
        User.objects.create_user('admin','admin@163.com','admin123456')

    def test_add_admin(self):
        '''测试添加用户'''

        user = User.objects.get(username="admin")
        self.assertEqual(user.username,"admin")
        self.assertEqual(user.email,"admin@163.com")

    def test_login_adtion_username_password_null(self):
        '''用户名密码为空'''

        test_data = {'username':'','password':''}
        response = self.client.post('/login_action/',data=test_data)
        self.assertEqual(response.status_code,200)
        self.assertIn(b"username or password error!",response.content)

    def test_login_username_password_error(self):
        '''用户名密码错误'''

        test_data = {'username':'abce','password':'123456'}
        response = self.client.post('/login_action/',data=test_data)
        self.assertEqual(response.status_code,200)
        self.assertIn(b"username or password error!",response.content)

    def test_login_success(self):
        '''登录成功'''

        test_data = {'username':'admin','password':'admin123456'}
        response = self.client.post('/login_action/',data=test_data)
        self.assertEqual(response.status_code,302)

class EventManageTest(TestCase):
    '''发布会管理测试'''

    def setUp(self):
        User.objects.create_user('admin', 'admin@163.com', 'admin123456')
        Event.objects.create(name="xiaomi5",limit=2000,address="beijing",status=1,start_time='2018-02-28 14:00:00')
        self.login_user = {'username':'admin','password':'admin123456'}

    def test_event_mange_success(self):
        '''测试发布会:xiaomi5'''

        response = self.client.post('/login_action/',data=self.login_user)
        response = self.client.post('/event_manage/')
        self.assertEqual(response.status_code,200)
        self.assertIn(b"xiaomi5",response.content)
        self.assertIn(b"beijing",response.content)

    def test_eventmanage_search_success(self):
        '''测试发布会搜索'''

        response = self.client.post('/login_action/',data=self.login_user)
        response = self.client.post('/search_name/',{"username":"xiaomi5"})
        self.assertEqual(response.status_code,200)
        self.assertIn(b"xiaomi5",response.content)
        self.assertIn(b"beijing", response.content)

class GuestManageTest(TestCase):
    '''嘉宾管理'''

    def setUp(self):
        User.objects.create_user('admin', 'admin@163.com', 'admin123456')
        Event.objects.create(id=1,name="xiaomi5", limit=2000, address="beijing", status=1, start_time='2018-02-28 14:00:00')
        Guest.objects.create(realname="lixiaoman",phone=13996365087,email='470331325@qq.com',sign=0,event_id=1)
        self.login_user = {'username': 'admin', 'password': 'admin123456'}

    def test_guest_manage_success(self):
        '''测试嘉宾信息lixiaoman'''

        response = self.client.post('/login_action/',data=self.login_user)
        response = self.client.post('/guest_manage/')
        self.assertEqual(response.status_code,200)
        self.assertIn(b"lixiaoman",response.content)
        self.assertIn(b"13996365087", response.content)

 

今天突然就给我报错了,报错的内容如下:

二狗子的耳朵的主页 二狗子的耳朵 | 菜鸟二级 | 园豆:210
提问于:2018-03-06 11:15
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册