Take full advantage of Visual Studio Code's support for unittesting
tests.py
from django.test import TestCase
from django import setup
import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "django_project.settings")
setup()
Create your tests here.
from .models import Post
class PostTestCase(TestCase):
def test_queryset_exists(self):
qs = Post.objects.all()
self.assertTrue(qs.exists())
14 окт 2024