python django tests用法
直接运行默认的tests.py 啥都没有,我们需要改为这样
python
import os, django
from django.test import TestCase
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "myblog.settings")
django.setup()
from article.models import Cover
class TestCase(TestCase):
def setUp(self):
print('start')
# 测试函数执行后执行
def tearDown(self):
print("======in tearDown")
def test(self):
pass
import os, django
from django.test import TestCase
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "myblog.settings")
django.setup()
from article.models import Cover
class TestCase(TestCase):
def setUp(self):
print('start')
# 测试函数执行后执行
def tearDown(self):
print("======in tearDown")
def test(self):
pass