Unittest не обнаруживает мой недавно созданный тестовый файл в Django

Я работаю над проектом Django, в котором был предварительно написан "пример теста". Когда я запускаю python manage.py test, он запускает/обнаруживает только файл примера теста.

Я хочу протестировать модель, поэтому структура моих тестов немного отличается, но я не могу понять, почему unittest не обнаруживает их.

Примечание: Тесты являются рудиментарными

# test_example.py
from rest_framework import status
from rest_framework.test import APITestCase


class AuthenticationTestCase(APITestCase):
   def setUp(self):
       self.user_data = {
           "username": "test1",
           "email": "test@foo.com",
           "password": "123456",
       }

   def test_not_authenticated_protected_endpoint(self):
       """Try to access a protected endpoint without a token"""

       response = self.client.get(f"/api/users/{self.user_data['username']}")
       self.assertEqual(response.status_code, status.HTTP_401_UNAUTHORIZED)

   def test_authenticated_protected_endpoint(self):
       """Try to access a protected endpoint with a valid token"""

       # Register a user
       register_response = self.client.post(
           "/auth/register", data=self.user_data, format="json"
       )
       self.assertEqual(register_response.status_code, status.HTTP_201_CREATED)

       data = register_response.json()
       self.assertIn("token", data)

       # Access protected route with credentials
       users_response = self.client.get(
           f"/api/users/{self.user_data['username']}",
           format="json",
           **{"HTTP_X-ACCESS-TOKEN": data.get("token")},
       )
       self.assertEqual(users_response.status_code, status.HTTP_200_OK)

       data = users_response.json()
       self.assertEqual(data, [])

Вот мой тест:

# test_conversation_group.py
from django.test import TestCase

from messenger_backend.models import ConversationGroup
from messenger_backend.models import Conversation
from messenger_backend.models import User

class ConversationGroupTest(TestCase):
  def setUp(cls):
    cls.thomas = User(
      username="thomas",
      email="thomas@email.com",
      password="123456",
      photoUrl="https://res.cloudinary.com/dmlvthmqr/image/upload/v1607914467/messenger/thomas_kwzerk.png",
    )
    cls.thomas.save()


    def test_something_that_will_pass(self):
        self.assertFalse(False)

    def test_1(self):
      self.assertEqual(self.thomas.username, "thomas")


Структура каталога:

├─tests
├── __init__.py
├── test_example.py
└── test_conversation_group.py

Спасибо!

Вернуться на верх